[CMake] linker doesnt find shared library

Rolf Eike Beer eike at sf-mail.de
Thu Jan 12 15:20:34 EST 2012


Thorsten Wagner wrote:
> Hello,
> 
> i have a library "libpnt.so" under /usr/local/lib/pnt.
> I've added a pnt.conf with this path  under /etc/ld.so.conf.d/ and
> execute ldconfig
> 
> ldconfig -v | grep libpnt.so finds the library:
> 
> "libpnt.so.0 -> libpnt.so.0.8.1"
> 
> In the CMakeList.txt i try to link against the target:
> "TARGET_LINK_LIBRARIES(profil pnt ...)"
> 
> But the linker returns: "cannot find -lpnt".
> 
> When the library is saved under /usr/local/lib, everything works fine...
> 
> Any suggestions?

TARGET_LINK_LIBRARIES(profil /usr/local/lib/pnt/libpnt.so)

What's in ld.so.conf is for the dynamic linker on program execution, it has 
nothing to do with the paths used by the linker that creates the program. Just 
use the absolute paths to the libraries you want to link. Or use 
FIND_LIBRARY() to get this path, which will return an absolute path and looks 
in some default places for you.

Eike


More information about the CMake mailing list