<div>You do not need an "add_dependencies" call after the add_executable, you need a "target_link_libraries" to tell the exe to link in the library...</div><div><br></div><div>HTH,</div><div>David</div>
<div><br></div><div><div class="gmail_quote">On Fri, Nov 14, 2008 at 1:23 PM, Neal Meyer <span dir="ltr"><<a href="mailto:nmeyer@dottedzebra.com">nmeyer@dottedzebra.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I built an extremely simple project. Contains main.cpp, and then a library with widget.cpp init. here is the CMakeLists.txt that I'm using<br><br>project( c++_cmd_line )<br>CMAKE_MINIMUM_REQUIRED(VERSION 2.6)<br><br>
#setup the output directories<br>set( LIB_OUT_DIR ${CMAKE_BINARY_DIR}/bin/lib )<br>set( EXE_OUT_DIR ${CMAKE_BINARY_DIR}/bin )<br>set( EXECUTABLE_OUTPUT_PATH ${EXE_OUT_DIR} )<br>set( LIBRARY_OUTPUT_PATH ${LIB_OUT_DIR} )<br>
<br>add_library( widget STATIC widget.h widget.cpp )<br>add_executable( c++_cmd_line main.cpp ) <br><br>add_dependencies( c++_cmd_line widget )<br><br><br>main.cpp is just Hello world that calls a couple made up functions in the widget class to get the dependencies. And here is what the make spits out<br>
<br>Scanning dependencies of target widget<br>[ 50%] Building CXX object CMakeFiles/widget.dir/widget.cpp.o<br>Linking CXX static library bin/lib/libwidget.a<br>[ 50%] Built target widget<br>Scanning dependencies of target c++_cmd_line<br>
[100%] Building CXX object CMakeFiles/c++_cmd_line.dir/main.cpp.o<br>Linking CXX executable bin/c++_cmd_line<br>Undefined symbols:<br> "Widget::get_i()", referenced from:<br> _main in main.cpp.o<br> "Widget::get_j()", referenced from:<br>
_main in main.cpp.o<br> "Widget::Widget()", referenced from:<br> _main in main.cpp.o<br>ld: symbol(s) not found<br>collect2: ld returned 1 exit status<br>make[2]: *** [bin/c++_cmd_line] Error 1<br>make[1]: *** [CMakeFiles/c++_cmd_line.dir/all] Error 2<br>
make: *** [all] Error 2<br><br>I've tried moving the build directory around and even running cmake directly in my source directory, but to no avail.<br><font color="#888888"><br>-Neal</font><div><div></div><div class="Wj3C7c">
<br><br><br><div class="gmail_quote">On Fri, Nov 14, 2008 at 5:16 AM, Michael Jackson <span dir="ltr"><<a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.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><br>
On Nov 13, 2008, at 7:59 PM, Neal Meyer wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
I have a project that I have been working on for a while using the Visual Studio generator in Windows, and I am now attempting to build in on Mac. Right now it's very early and I'm having problems building any of the executables using the Unix Makefile generation or the XCode generator. It's basically just a couple of static libraries, that need to get linked into to build the executable. I have set them up as dependencies in the CMake files, and in XCode they show as dependencies, and the Unix builds them in the proper order. But it doesn't appear to try to link them in via the make files. I'm makefile illiterate so there maybe something I'm missing in them.<br>
<br>
Is there anywhere I could start to try to figure out what's wrong?<br>
<br>
-Neal<br>
</blockquote>
<br></div></div>
Do you get a link error when you try to compile? Does the code compile at all? Can yo post the error messages to the list?<br>
<br>
<br>
_________________________________________________________<br>
Mike Jackson <a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a><br>
BlueQuartz Software <a href="http://www.bluequartz.net" target="_blank">www.bluequartz.net</a><br>
Principal Software Engineer Dayton, Ohio<br>
<br>
<br>
<br>
</blockquote></div><br>
</div></div><br>_______________________________________________<br>
CMake mailing list<br>
<a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br></div>