Thanks for the reply.<br><br>I added "add_dependencies( lib1 lib2 )",
"add_dependencies( lib2 lib1 )", and "add_dependencies( execthing lib1
lib2 )" in their appropriate places, and changed the libraries to
STATIC, but no change.<br>
<br>Yes, everything compiles when i build the libraries and executables
separately; it fails on the link step after this, with "undefined
reference" to every library function used.<br><br>I'm unfamiliar with 'nm', can you be more specific as to what I should be looking for?<br><br><br><div class="gmail_quote">On Tue, Jun 16, 2009 at 4:55 PM, Tyler Roscoe <span dir="ltr"><<a href="mailto:tyler@cryptio.net">tyler@cryptio.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Tue, Jun 16, 2009 at 03:41:51PM -0500, Mark Lohry wrote:<br>
> I have a number of subdirectories, each containing source to be built into<br>
> their own libraries, which contain many interdependencies. I'm trying to<br>
> build an executable to link against these libraries, and I'm getting a<br>
> console full of "undefined reference to..." errors on linking step. The<br>
> libraries and executable source all compile individually without issue.<br>
><br>
> Structure is like so:<br>
><br>
> # top-level CMakeLists.txt<br>
> project( proj )<br>
> ADD_SUBDIRECTORY( lib )<br>
> ADD_SUBDIRECTORY( src )<br>
><br>
><br>
> # /lib/CMakeLists.txt<br>
> ADD_SUBDIRECTORY( lib1 )<br>
> ADD_SUBDIRECTORY( lib2 )<br>
><br>
><br>
> # /lib/lib1/CMakeLists.txt<br>
> include_directories( ${proj_SOURCE_DIR}/lib )<br>
> set( lib1_SRCS<br>
> ..... bunch of c++ sources )<br>
> add_library( lib1 SHARED ${lib1_SRCS} )<br>
><br>
><br>
> # /lib/lib2/CMakeLists.txt<br>
> include_directories( ${proj_SOURCE_DIR}/lib )<br>
> set( lib2_SRCS<br>
> ..... bunch of c++ sources )<br>
> add_library( lib2 SHARED ${lib2_SRCS} )<br>
><br>
><br>
> # src/CMakeLists.txt<br>
> include_directories( ${proj_SOURCE_DIR}/lib )<br>
> set( execthing_SRCS<br>
> .... bunch of C++ sources )<br>
> add_executable( execthing ${execthing_SRCS} )<br>
> target_link_libraries( execthing lib1 lib2 )<br>
<br>
</div></div>This all looks reasonable to me, so the devil is probably in the<br>
details. Are you sure all your paths make sense? Can you use nm or<br>
dumpbin or whatever to see the "undefined" symbols in the libraries<br>
where you expect to find them?<br>
<br>
So if you build the libraries individually and then build the executable<br>
individually, everything works? You might try playing with some explicit<br>
add_dependencies() to see if there's some kind of build order problem.<br>
CMake should be smart enough to figure this out from your<br>
target_link_libraries, but maybe you have something strange going on<br>
under the covers?<br>
<font color="#888888"><br>
tyler<br>
</font></blockquote></div><br>