Hi,

I have built a static library lib1 and test program lib1test using the 
following CMAKE 2.6.2 commands without problems.

INCLUDE_DIRECTORIES( /usr/local/boost_1_39_0 )
ADD_LIBRARY( lib1 STATIC ${lib1_srcs} )

ADD_EXECUTABLE( lib1test lib1test.cpp )
LINK_DIRECTORIES( /usr/local/lib ) # boost stuff
TARGET_LINK_LIBRARIES( lib1test lib1 boost_filesystem-gcc42-mt 
boost_system-gcc42-mt )
 
When attempting to build a 2nd static library lib2 (which uses code in lib1) 
and test program lib2test with a similar script  -

INCLUDE_DIRECTORIES( /home/john/lib1/src )
ADD_LIBRARY( lib2 STATIC ${lib2_srcs} )

ADD_EXECUTABLE( lib2test lib2test.cpp )
LINK_DIRECTORIES( /home/john/lib1/src ) ## doesn't work here
TARGET_LINK_LIBRARIES( lib2test lib2 lib1 boost_filesystem-gcc42-mt 
boost_system-gcc42-mt)

I get the following link error
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: 
cannot find -llib1

If LINK_DIRECTORIES is moved before ADD_EXECUTABLE -

LINK_DIRECTORIES( /home/john/lib1/src ) ## works here
ADD_EXECUTABLE( lib2test lib2test.cpp )
TARGET_LINK_LIBRARIES( lib2test lib2 lib1 boost_filesystem-gcc42-mt 
boost_system-gcc42-mt)

lib2test links and executes.

I would really appreciate some help with the following questions. 

1. Are the boost libraries statically or dynamically linked to lib1test?

2. Why does moving LINK_DIRECTORIES before ADD_EXECUTABLE appear to fix things?

3. The location of the boost libraries has not been specfied but lib2test still 
links?

TIA,

John.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to