0

I got this error

/usr/bin/ld: ../core/CMakeFiles/core.dir/logger.cpp.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC

I tried

set_target_properties(emsim PROPERTIES POSITION_INDEPENDENT_CODE ON)

But this didn't work, I'm trying to link pybind11, how should I deal with this error?

Thanks!

Justin
  • 21
  • 4
  • https://stackoverflow.com/questions/38296756/what-is-the-idiomatic-way-in-cmake-to-add-the-fpic-compiler-option/38297422#38297422 –  Mar 24 '21 at 03:02
  • Just a guess. After your project call set CMAKE_POSITION_INDEPENDENT_CODE to ON. –  Mar 24 '21 at 03:03
  • 3
    Please, provide more code, preferable as [mcve]. The path in the error message - `../core/CMakeFiles/core.dir/logger.cpp.o` - suggests, that this file has been created as a part of `core` target. So it is not clear how `emsim` target, for which you set properties, is related to the problem. – Tsyvarev Mar 24 '21 at 08:01

0 Answers0