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

S'orlok Reaves sorlok_reaves at yahoo.com
Mon Sep 23 22:54:38 EDT 2013



Ah, thanks, it's probably LD_LIBRARY_PATH. I'll install boost into a different path and try again.

Seth




----- Original Message -----
From: Alexander Neundorf <a.neundorf-work at gmx.net>
To: cmake at cmake.org; S'orlok Reaves <sorlok_reaves at yahoo.com>
Cc: 
Sent: Tuesday, September 24, 2013 4:12 AM
Subject: Re: [CMake] Cmake appears to substitute -llibrary when a full path is given.

On Monday 23 September 2013, 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? 

There is some environment variable involved, LIBDIR or LIBRARY_PATH or 
something like that, I don't remember exactly right now. grep your env for 
"LIB".
If the path to the library is contained in this environment variable, the full 
path is not used, but instead -l is used.

Alex



More information about the CMake mailing list