首页 > 解决方案 > 如何在 cmake 中包含 -fPIC?

问题描述

我收到了这个错误

/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

我试过了

set_target_properties(emsim PROPERTIES POSITION_INDEPENDENT_CODE ON)

但这不起作用,我正在尝试链接pybind11,我应该如何处理这个错误?

谢谢!

标签: cmakepybind11

解决方案


推荐阅读