Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing compiler flag for position independent code (-fPIC) #128

Open
bashbaug opened this issue Jan 27, 2025 · 0 comments
Open

missing compiler flag for position independent code (-fPIC) #128

bashbaug opened this issue Jan 27, 2025 · 0 comments

Comments

@bashbaug
Copy link
Contributor

Whenever I update the OpenCL SDK and build into an existing build directory I get a link error:

[ 74%] Linking CXX shared library libOpenCLSDKCpp.so
/usr/bin/ld: libsfml-system-s.a(Err.cpp.o): warning: relocation against `_ZTVSt9basic_iosIcSt11char_traitsIcEE@@GLIBCXX_3.4' in read-only section `.text.unlikely'
/usr/bin/ld: libsfml-window-s.a(Window.cpp.o): relocation R_X86_64_PC32 against symbol `_ZNKSt5ctypeIcE8do_widenEc' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

Removing everything in the build directory and starting fresh does seem to "fix" the build, but this also redownloads all dependencies, etc, so it's a fairly big hammer. I think it would be better to build at least the OpenCL SDK static libraries with position independent code, instead.

For now, I've added this to the top of my OpenCL SDK CMakeLists.txt, and it seems to be working for me:

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

We could be more selective if we choose to, though, and instead enable position independent code for specific targets:

set_property(TARGET my_target_name PROPERTY POSITION_INDEPENDENT_CODE ON)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant