[CMake] Cmake appears to substitute -llibrary when a full path is given.

Andreas Naumann Andreas-Naumann at gmx.net
Wed Sep 25 15:03:16 EDT 2013


Hi Seth,
I had the same problem some time ago. In my case, the environment 
variable LIBRARY_PATH contained the boost directory, which instructs the 
linker to use it as standard library directory.
CMake asks the compiler for implicit linking directories. I am not 
completly sure, but the directories should be documented in some 
CMakeFiles/*Output* file.

I hope, that helps a little.
Andreas

On 23.09.2013 10:01, S'orlok Reaves wrote:
> Good afternoon all,
>
>
> This is my first post to this list, so please redirect me if I'm in the wrong place. So far cmake has been great, but I've run into an issue that I am having trouble understanding.
>
> I'm searching for the Boost libs on a server that has two different versions installed. One is in my home directory; the other is a system-wide install (which is older).
>
> In my CMakeLists.txt:
>
> set(Boost_NO_SYSTEM_PATHS ON)
> set(BOOST_ROOT "/home/me/opt")
> find_package(Boost COMPONENTS system REQUIRED)
> MESSAGE("${Boost_LIBRARIES}")
> #later:
> target_link_libraries (My_Program ${Boost_LIBRARIES})
>
>
> This prints out the following, so I know the correct library is indeed found:
> /home/me/opt/lib/libboost_system.so
>
>
> Now, I "make" the project, and everything compiles, but fails to link, specifying several missing symbols in boost::system. The linker command includes the following:
> #g++ ....etc., then:
> -o ../My_Program -rdynamic /usr/local/lib64/libsoci_core.so -lboost_system -Wl,-rpath,/usr/local/lib64
>
>
> If I change it to the following, it compiles, links, and runs fine:
> -o ../My_Program -rdynamic /usr/local/lib64/libsoci_core.so /home/me/opt/lib/libboost_system.so -Wl,-rpath,/usr/local/lib64
>
> Clearly the "-lboost_system" flag is catching the old libraries. From reading the cmake docs, I was under the impression that the full path (/home/me/opt/lib/libboost_system.so) would only be truncated to an "-lboost_system" if it was on the implicit path (e.g., /usr/lib). In that case, I have two questions:
>
> 1) Why is boost_system not being included via its complete path? Is this a bug, or am I doing something wrong?
> 2) Why is soci_core being included by the full path. Is it because "/usr/local" is not on the implicit path?
>
> The second question is just out of curiosity; it is the first question that is causing me a lot of grief right now. Any suggestions?
>
> The server I'm compiling on is running Debian Squeeze (6.0.7), with a locally-installed version of cmake (2.8.11.2).
>
> Thanks,
> Seth
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



More information about the CMake mailing list