Novice question:

I have a number of subdirectories, each containing source to be built into
their own libraries, which contain many interdependencies. I'm trying to
build an executable to link against these libraries, and I'm getting a
console full of "undefined reference to..." errors on linking step. The
libraries and executable source all compile individually without issue.

Structure is like so:

# top-level CMakeLists.txt
project( proj )
ADD_SUBDIRECTORY( lib )
ADD_SUBDIRECTORY( src )


# /lib/CMakeLists.txt
ADD_SUBDIRECTORY( lib1 )
ADD_SUBDIRECTORY( lib2 )


# /lib/lib1/CMakeLists.txt
include_directories( ${proj_SOURCE_DIR}/lib )
set( lib1_SRCS
  ..... bunch of c++ sources )
add_library( lib1 SHARED ${lib1_SRCS} )


# /lib/lib2/CMakeLists.txt
include_directories( ${proj_SOURCE_DIR}/lib )
set( lib2_SRCS
  ..... bunch of c++ sources )
add_library( lib2 SHARED ${lib2_SRCS} )


# src/CMakeLists.txt
include_directories( ${proj_SOURCE_DIR}/lib )
set( execthing_SRCS
 .... bunch of C++ sources )
add_executable( execthing ${execthing_SRCS} )
target_link_libraries( execthing lib1 lib2 )


All the tutorials I've been reading suggest that this is all that is
necessary to build libraries and cmake will handle the dependencies, but
linking is failing. System is linux 2.6, gcc 4.2.1. Any point in the right
direction would be appreciated. Let me know what other info is needed.

Thanks in advance,
Mark
_______________________________________________
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