I tried to install a library but I have got the following error after running make. How to recompile with flag?
make Scanning dependencies of target pwrutils Linking CXX shared library libpwrutils.so /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_system.a(error_code.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC ,/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_system.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status make[2]: * [libpwrutils/libpwrutils.so.1.0] Error 1 make[1]: * [libpwrutils/CMakeFiles/pwrutils.dir/all] Error 2 make: *** [all] Error 2
In case if someone runs into this, and adding the fPIC
flag to your project doesn't help:
I had the same problem, and my library had the -fPIC
flag set up correctly within my CMakeLists, and I could verify it when looking at the compilation logs, for example, I saw:
/usr/bin/c++ -fPIC ... etc.
Then I realized I link against couple other libraries, so I had to recompile both of them with the -fPIC
, and that's where the problem was.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With