CMAKE - runtime library hidden files

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-25 07:17:19

问题


I am running Linux Redhat, I have Anaconda installed and I am trying to install a program (libspimage) using CMAKE amd I get the following warning/error:

CMake Warning at src/CMakeLists.txt:74 (ADD_LIBRARY): Cannot generate a safe runtime search path for target _spimage_pybackend because files in some directories may conflict with libraries in implicit directories: runtime library [libtiff.so.5] in /usr/lib64 may be hidden by files in: /home/michantia/anaconda2/lib

Some of these libraries may not be found correctly.

When I do:

echo $PATH

I get:

/home/mi_a/anaconda2/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/michantia/.local/bin:/home/michantia/bin

I tried:

export PATH=/usr/lib64:$PATH

hoping cmake would find the libraries in this directory before finding them in anancoda's, but that did not work. I also tried two other similar suggestions for a similar problem that I saw in stackoverflow, but that did not work.

Any other ideas are highly welcomed.


回答1:


Warning message

Cannot generate a safe runtime search path for target

is related neither with CMake ability to find a library (libtiff.so.5 in your case) nor with a linker ability to link the library.

The warning message means that when a target (_spimage_pybackend) will be loaded, the loader will be unable to choose the correct library: according to the loader's algorithm and the target's setting, file /home/michantia/anaconda2/lib/libtiff.so.5 will be choosen instead of proper one /usr/lib64/libtiff.so.5.

The error is usually resulted in linking into the single target two libraries from different directories, when the directory with a second library also contains a file with the name of the first library:

  1. Directory /usr/lib64 contains a library libtiff.so.5, which is linked into the target.
  2. Directory /home/michantia/anaconda2/lib contains a library <A> which is also linked into the target; but this directory also contains a file libtiff.so.5.

According to CMake algorithm, runpath for the binary file of such target will include both directories, so both libraries could be found. But such runpath confuses the loader to find the first library properly.

Except from avoiding such situation (when a library is contained in two directories), one hardly is able to handle this warning.



来源:https://stackoverflow.com/questions/48447728/cmake-runtime-library-hidden-files

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