linux - CMake: find_library result depends on selected compiler? -


i'm confused how find_library supposed work, , don't know if cmake bug, or misuse or misconfiguration on part. have installed both gcc , pgi compilers, , when try simple cmakelists.txt file (with both 2.8.11 , 3.5.1):

cmake_minimum_required(version 2.8.11) find_library( libdl dl ) message("libdl ${libdl}") 

i following:

$ cc=gcc cxx=g++ cmake . -- c compiler identification gnu 4.8.4 -- cxx compiler identification gnu 4.8.4 -- check working c compiler: /usr/bin/gcc -- check working c compiler: /usr/bin/gcc -- works -- detecting c compiler abi info -- detecting c compiler abi info - done -- check working cxx compiler: /usr/bin/g++ -- check working cxx compiler: /usr/bin/g++ -- works -- detecting cxx compiler abi info -- detecting cxx compiler abi info - done libdl /usr/lib/x86_64-linux-gnu/libdl.so -- configuring done -- generating done -- build files have been written to: /home/molcas-test/test/cmake 

that's ok, but:

$ cc=pgcc cxx=pgc++ cmake . -- c compiler identification pgi 17.1.0 -- cxx compiler identification pgi 17.1.0 -- check working c compiler: /opt/pgi/linux86-64/17.1/bin/pgcc -- check working c compiler: /opt/pgi/linux86-64/17.1/bin/pgcc -- works -- detecting c compiler abi info -- detecting c compiler abi info - done -- check working cxx compiler: /opt/pgi/linux86-64/17.1/bin/pgc++ -- check working cxx compiler: /opt/pgi/linux86-64/17.1/bin/pgc++ -- works -- detecting cxx compiler abi info -- detecting cxx compiler abi info - done libdl libdl-notfound -- configuring done -- generating done -- build files have been written to: /home/molcas-test/test/cmake 

note dl not found.

leaving out either pgcc or pgc++ causes library found, must in how compilers configured. , yet compiling command line finds dl without complain:

$ pgcc -ldl hello_world.c -o hello_world $ ./hello_world hello world! 

so believe something's not right if pgcc can find library , cmake can't. of course set lib=/usr/lib/x86_64-linux-gnu before running cmake, force search in directory, doesn't feel right.

edit: seems problem gcc /lib/x86_64-linux-gnu included in cmake_c_implicit_link_directories, cmake_library_architecture set. pgcc directory absent , cmake_library_architecture empty.

and directory missing pgcc because pgcc -v doesn't include -l/lib/x86_64-linux-gnu flag, while gcc -v does. however, ld finds libraries in directory in either case.

so cmake not searching libraries in same places ld, should it? there easy way change this, other than, e.g., manually inspecting files in /etc/ld.so.conf.d , setting lib environment variable?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -