<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">DON&#39;T
EVER do something like this unless you really know what you&#39;re doing.
The proper way of doing this is to use the Debug configuration at
configure-time:<br><br>
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-Wall /path/to/source<br></blockquote><br>Thanks for the tip! I had just put the warnings on to find out some more about what could be going wrong<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
This should be:<div class="im"><br>
<br>
TARGET_LINK_LIBRARIES( calClient<br>
 ${OPENCV_LIBRARIES}<br></div><div><div class="h5">
 callibs<br>
 )</div></div></blockquote><div><br>I changed it, the make went without any appreciable effect. Here&#39;s hte output:<br> </div><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
pmonso@delucia:~/YARP/Calclient$ make VERBOSE=1<br>/usr/local/bin/cmake -H/home/pmonso/YARP/Calclient -B/home/pmonso/YARP/Calclient --check-build-system CMakeFiles/Makefile.cmake 0<br>/usr/local/bin/cmake -E cmake_progress_start /home/pmonso/YARP/Calclient/CMakeFiles /home/pmonso/YARP/Calclient/CMakeFiles/progress.make<br>
make -f CMakeFiles/Makefile2 all<br>make[1]: Entering directory `/home/pmonso/YARP/Calclient&#39;<br>make -f lib/CMakeFiles/callibs.dir/build.make lib/CMakeFiles/callibs.dir/depend<br>make[2]: Entering directory `/home/pmonso/YARP/Calclient&#39;<br>
cd /home/pmonso/YARP/Calclient &amp;&amp; /usr/local/bin/cmake -E cmake_depends &quot;Unix Makefiles&quot; /home/pmonso/YARP/Calclient /home/pmonso/YARP/Calclient/lib /home/pmonso/YARP/Calclient /home/pmonso/YARP/Calclient/lib /home/pmonso/YARP/Calclient/lib/CMakeFiles/callibs.dir/DependInfo.cmake --color=<br>
make[2]: Leaving directory `/home/pmonso/YARP/Calclient&#39;<br>make -f lib/CMakeFiles/callibs.dir/build.make lib/CMakeFiles/callibs.dir/build<br>make[2]: Entering directory `/home/pmonso/YARP/Calclient&#39;<br>make[2]: Nothing to be done for `lib/CMakeFiles/callibs.dir/build&#39;.<br>
make[2]: Leaving directory `/home/pmonso/YARP/Calclient&#39;<br>/usr/local/bin/cmake -E cmake_progress_report /home/pmonso/YARP/Calclient/CMakeFiles  3 4 5<br>[ 60%] Built target callibs<br>make -f CMakeFiles/calClient.dir/build.make CMakeFiles/calClient.dir/depend<br>
make[2]: Entering directory `/home/pmonso/YARP/Calclient&#39;<br>cd /home/pmonso/YARP/Calclient &amp;&amp; /usr/local/bin/cmake -E cmake_depends &quot;Unix Makefiles&quot; /home/pmonso/YARP/Calclient /home/pmonso/YARP/Calclient /home/pmonso/YARP/Calclient /home/pmonso/YARP/Calclient /home/pmonso/YARP/Calclient/CMakeFiles/calClient.dir/DependInfo.cmake --color=<br>
make[2]: Leaving directory `/home/pmonso/YARP/Calclient&#39;<br>make -f CMakeFiles/calClient.dir/build.make CMakeFiles/calClient.dir/build<br>make[2]: Entering directory `/home/pmonso/YARP/Calclient&#39;<br>Linking CXX executable calClient<br>
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/calClient.dir/link.txt --verbose=1<br>/usr/bin/c++   -g -Wall  -fPIC CMakeFiles/calClient.dir/calClient.cpp.o CMakeFiles/calClient.dir/chaser.cpp.o  -o calClient -rdynamic -Llib /home/pmonso/YARP/yarp-2.2.2/lib/libYARP_dev.a /home/pmonso/YARP/yarp-2.2.2/lib/libYARP_sig.a /home/pmonso/YARP/yarp-2.2.2/lib/libYARP_OS.a -lACE -lcv -lcvaux -lcxcore -lhighgui lib/libcallibs.a /home/pmonso/YARP/yarp-2.2.2/lib/libYARP_dev.a /home/pmonso/YARP/yarp-2.2.2/lib/libYARP_sig.a /home/pmonso/YARP/yarp-2.2.2/lib/libYARP_OS.a -lACE -Wl,-rpath,lib <br>
CMakeFiles/calClient.dir/calClient.cpp.o: In function `incrementalCalibrate(yarp::dev::IPositionControl*, yarp::dev::IEncoders*)&#39;:<br>/home/pmonso/YARP/Calclient/calClient.cpp:276: undefined reference to `print_double_array(double const*, int)&#39;<br>
/home/pmonso/YARP/Calclient/calClient.cpp:277: undefined reference to `print_double_array(double const*, int)&#39;<br>/home/pmonso/YARP/Calclient/calClient.cpp:295: undefined reference to `print_double_array(double const*, int)&#39;<br>
CMakeFiles/calClient.dir/calClient.cpp.o: In function `calibrate(yarp::dev::IPositionControl*, yarp::dev::IEncoders*)&#39;:<br>/home/pmonso/YARP/Calclient/calClient.cpp:155: undefined reference to `print_double_array(double const*, int)&#39;<br>
CMakeFiles/calClient.dir/calClient.cpp.o: In function `randomCalibrate(yarp::dev::IPositionControl*, yarp::dev::IEncoders*)&#39;:<br>/home/pmonso/YARP/Calclient/calClient.cpp:207: undefined reference to `print_double_array(double const*, int)&#39;<br>
CMakeFiles/calClient.dir/calClient.cpp.o:/home/pmonso/YARP/Calclient/calClient.cpp:208: more undefined references to `print_double_array(double const*, int)&#39; follow<br>collect2: ld returned 1 exit status<br>make[2]: *** [calClient] Error 1<br>
make[2]: Leaving directory `/home/pmonso/YARP/Calclient&#39;<br>make[1]: *** [CMakeFiles/calClient.dir/all] Error 2<br>make[1]: Leaving directory `/home/pmonso/YARP/Calclient&#39;<br>make: *** [all] Error 2<br>pmonso@delucia:~/YARP/Calclient$ <br>
</blockquote><br>Thank you very much for the quick response!<br><br>pol<br><br><div class="gmail_quote">2009/8/25 Michael Wild <span dir="ltr">&lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
On 25. Aug, 2009, at 15:06, Pol Monsó IRI 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;">
Hello cmake users!<br>
<br>
I&#39;m quite new to cmake as well as makefiles, and i&#39;ve bumped the same<br>
trouble twice. I&#39;m trying to break a source code into several libraries and<br>
a main program. The scenario has one main executable called calClient which<br>
uses functions from three libraries, let&#39;s say 1A 1B and 2C. Everybody uses<br>
library 2C, that is calClient, 1A and 1B. I&#39;ve stored the source codes of 1A<br>
1C and 2C in a subdirectory called lib/ toghether with a CMakeLists.txt :<br>
<br>
FIND_PACKAGE(YARP REQUIRED)<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
SET(PROJECT_LIBS<br>
  2C.cpp<br>
  2C.h<br>
  1B.cpp<br>
  1B.h<br>
  1A.cpp<br>
  1A.hpp<br>
)<br>
<br>
add_library(callibs ${PROJECT_LIBS})<br>
</blockquote>
<br>
<br>
In the upper directory, toghether with the source code of the main program,<br>
I have:<br>
<br>
project(calibration)<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
cmake_minimum_required(VERSION 2.6)<br>
<br>
set(CMAKE_CXX_FLAGS &quot;-g -Wall&quot;)<br>
</blockquote></blockquote>
<br></div>
</blockquote><div><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
set(PROJECT_SRC<br>
  calClient.cpp<br>
  calClient.hpp<br>
  chaser.cpp<br>
  chaser.hpp<br>
)<br>
<br>
FIND_PACKAGE(YARP REQUIRED)<br>
FIND_PACKAGE(OpenCV REQUIRED)<br>
<br>
add_subdirectory(lib)<br>
<br>
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/lib)<br>
link_directories(lib)<br>
<br>
INCLUDE_DIRECTORIES(${OPENCV_INCLUDE_DIR})<br>
<br>
ADD_EXECUTABLE(calClient ${PROJECT_SRC})<br>
TARGET_LINK_LIBRARIES( calClient ${OPENCV_LIBRARIES} )<br>
TARGET_LINK_LIBRARIES( calClient callibs )<br>
</blockquote></blockquote>
<br></div>
</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Every header includes the headers of the files which contains the functions<br>
that it needs. So, calClient.hpp actually includes 1A, 1B and 2C.<br>
<br>
The output of the make command is then:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
[ 60%] Built target callibs<br>
Linking CXX executable calClient<br>
CMakeFiles/calClient.dir/calClient.cpp.o: In function<br>
`incrementalCalibrate(yarp::dev::IPositionControl*, yarp::dev::IEncoders*)&#39;:<br>
/home/pmonso/YARP/Calclient/calClient.cpp:276: undefined reference to<br>
`print_double_array(double const*, int)&#39;<br>
/home/pmonso/YARP/Calclient/calClient.cpp:277: undefined reference to<br>
`print_double_array(double const*, int)&#39;<br>
/home/pmonso/YARP/Calclient/calClient.cpp:295: undefined reference to<br>
`print_double_array(double const*, int)&#39;<br>
CMakeFiles/calClient.dir/calClient.cpp.o: In function<br>
`calibrate(yarp::dev::IPositionControl*, yarp::dev::IEncoders*)&#39;:<br>
/home/pmonso/YARP/Calclient/calClient.cpp:155: undefined reference to<br>
`print_double_array(double const*, int)&#39;<br>
CMakeFiles/calClient.dir/calClient.cpp.o: In function<br>
`randomCalibrate(yarp::dev::IPositionControl*, yarp::dev::IEncoders*)&#39;:<br>
/home/pmonso/YARP/Calclient/calClient.cpp:207: undefined reference to<br>
`print_double_array(double const*, int)&#39;<br>
CMakeFiles/calClient.dir/calClient.cpp.o:/home/pmonso/YARP/Calclient/calClient.cpp:208:<br>
more undefined references to `print_double_array(double const*, int)&#39; follow<br>
collect2: ld returned 1 exit status<br>
make[2]: *** [calClient] Error 1<br>
make[1]: *** [CMakeFiles/calClient.dir/all] Error 2<br>
make: *** [all] Error 2<br>
<br>
</blockquote>
<br>
</blockquote>
<br></div></div>
In order for this output to be useful, we&#39;d need to see the link-line, which you can get by invoking<br>
<br>
make VERBOSE=1<div class="im"></div></blockquote><div><br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
The function print_double_array is located in the 2C source and header files<br>
which, as I said, is included in calClient header as well as in headers of<br>
1A and 1B.<br>
<br>
Does somebody know why linking fails? What I am doing wrong? It&#39;s driving me<br>
nuts!<br>
</blockquote>
<br></div>
It&#39;s probably that you invoke TARGET_LINK_LIBRARIES twice on the same target, as pointed out above.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Thanks alot for your help!<br>
<br>
pol<br>
<br>
</blockquote>
<br></div>
HTH<br>
<br>
Michael<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>