[CMake] Simple (?) lib linking question

William A. Hoffman billlist at nycap.rr.com
Thu Aug 3 22:59:45 EDT 2006



At 05:20 PM 8/3/2006, Anders Sundman wrote:
>Hi all!
>
>I'm new to cmake and I'm currently trying to get the hang of how it works.
>Unfortunately, I'm stuck with a simple (?) problem that I can't seem to
>work out. Any help will be much appreciated.
>
>I have created a minimal (OS X) example to demonstrate the problem
>(attached).
>
>In short, the problem is this: I have a 3:rd party lib (libb in my
>example), that should be used by one of my libs (liba in my example).
>Finally, my lib should be used by my app. When I try to create my (shared)
>library, the following error message appears:
>
>Scanning dependencies of target liba
>[ 50%] Building CXX object liba/CMakeFiles/liba.dir/liba.o
>Linking CXX shared library libliba.dylib
>/usr/bin/libtool: can't locate file for: -llibb
>/usr/bin/libtool: file: -llibb is not an object file (not allowed in a
>library)
>make[2]: *** [liba/libliba.dylib] Error 1
>make[1]: *** [liba/CMakeFiles/liba.dir/all] Error 2
>make: *** [all] Error 2
>
>If I build liba as a static library, the following message appears:
>
>Scanning dependencies of target liba
>[ 50%] Building CXX object liba/CMakeFiles/liba.dir/liba.o
>Linking CXX static library libliba.a
>[ 50%] Built target liba
>Scanning dependencies of target appex
>[100%] Building CXX object app/CMakeFiles/appex.dir/app.o
>Linking CXX executable appex
>/usr/bin/ld: can't locate file for: -llibb
>collect2: ld returned 1 exit status
>make[2]: *** [app/appex] Error 1
>make[1]: *** [app/CMakeFiles/appex.dir/all] Error 2
>make: *** [all] Error 2

Try make VERBOSE=1
to see what the link line actually is.

-Bill



More information about the CMake mailing list