[CMake] Static lib in project

Matthias Fulz mfulz at olznet.de
Sun Jan 15 00:02:51 EST 2012


It's working now - just had a typo inside the names.

Thanks @all.


On Sun, 2012-01-15 at 05:54 +0100, Matthias Fulz wrote:
> Have the following problem:
> 
> the lib is linked, but my testprogram can't link against it,
> because it's not found:
> 
> Built target
> aclibconfg                                                                                                                                                                         
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -ltestlib
> collect2: ld returned 1 exit status
> make[2]: *** [src/test/test] Error 1
> make[1]: *** [src/test/CMakeFiles/test.dir/all] Error 2
> make[1]: *** Waiting for unfinished jobs....
> 
> I've already added the directories to my target, but still not working:
> 
> src/test/CMakeLists.txt
> add_executable(test main.cpp)
> 
> link_directories(
>         ${CMAKE_BINARY_DIR}/src/testlib
>         )
> 
> include_directories(
>         ${CMAKE_SOURCE_DIR}/src/testlib
>         )
> 
> target_link_libraries(test testlib)
> 
> 
> The lib is build under src/testlib/testlib.a
> 
> Any help would be really nice !
> 
> BR,
> 
> Matthias
> 
> On Sat, 2012-01-14 at 23:42 +0100, Eric Noulard wrote:
> > src/CMakeList.txt
> > add_subdirectory(static_lib)
> > add_subdirectory(executable1)
> > add_subdirectory(executable2)
> > 
> > src/static_lib/CMakeLists.txt
> > add_library(InternalUse STATIC lib.cpp lib.hpp)
> > 
> > src/executable1/CMakeLists.txt
> > add_executable(exe1 main.cpp)
> > target_link_libraries(exe1 InternalUse)
> > install(TARGETS exe1 DESTINATION bin)
> > 
> > src/executable2/CMakeLists.txt
> > add_executable(exe2 main.cpp)
> > target_link_libraries(exe2 InternalUse)
> > install(TARGETS exe2 DESTINATION bin)
> > 
> > should work as expected.
> > 
> > "only inside this project" would mean
> > that you shouldn't install this library.
> > 
> 
> --
> 
> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120115/0b88da88/attachment.pgp>


More information about the CMake mailing list