CMake cannot generate a safe linker search path - yocto 2.4

孤人 提交于 2021-02-19 06:05:24

问题


I have 2 yocto pkgs that can be successfully compiled with gcc 5.4, cmake 3.6.1 on yocto 2.0.2 but I'm facing the following issue with: gcc 6.3, cmake 3.6.1 on yocto 2.4 .

After some research, I observed that yocto changed the sysroot structure (sysroot per package instead of a common sysroot). The error looks like this:

CMake Warning at src/mytest/CMakeLists.txt:71 (add_executable):
  Cannot generate a safe linker search path for target mytest because
  files in some directories may conflict with libraries in implicit
  directories:

link library [libpthread.so] in /local/build2/tmp/work/corei7-64-poky-linux/mytest/recipe-sysroot/usr/lib may be hidden by files in:
  /local/build2/tmp/work/corei7-64-poky-linux/mylib/recipe-sysroot/usr/lib


  Some of these libraries may not be found correctly.

Leading to linking error: ld: cannot find /lib/libpthread.so.0

I observed in some cmake generated files that mylib package exports its libraries with hardcoded pkg name, that will be later used by test pkg:

set_target_properties(mylib PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "/usr/include/;/{_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "-lpthread; mylib; /local/build2/tmp/work/corei7-64-poky-linux/mylib/recipe-sysroot/usr/lib/libpthread.so;"
)

Is there any way to avoid this kind of duplication? Or to remove the full paths from cmake generated files?

来源:https://stackoverflow.com/questions/48302419/cmake-cannot-generate-a-safe-linker-search-path-yocto-2-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!