CMakeList.txts: transfer from cmake to catkin_make
Hi,
I'm trying to transfer the opentld program into ROS package.
What I'm trying now is
- init a catkin package
- copy the content of opentld into
src
folder of catkin package - copy the folder 3rdparty and libopentld into
include
folder of catkin package modify the
CMakeLists.txt
file in catkin package according to theCMakeLists.txt
of TLD program4.1. add the
include_directories
4.2. add the
add_library
4.3 add the
if(BUILD_QOPENTLD)
Then I use catkin_make and no library or file missing is reported, but there are many errors about undefined reference when linking.
####
#### Running command: "make cmake_check_build_system" in "/home/aqua/catkin/build"
####
####
#### Running command: "make -j4 -l4" in "/home/aqua/catkin/build"
####
Linking CXX executable /home/aqua/catkin/devel/lib/tld/tld_node
Linking CXX shared library /home/aqua/catkin/devel/lib/libsrc/main.so
/usr/bin/ld: cannot open output file /home/aqua/catkin/devel/lib/libsrc/main.so: No such file or directory
collect2: ld returned 1 exit status
make[2]: *** [/home/aqua/catkin/devel/lib/libsrc/main.so] Error 1
make[1]: *** [tld/CMakeFiles/src/main.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
CMakeFiles/tld_node.dir/src/main/Main.cpp.o: In function `Main::doWork()':
Main.cpp:(.text+0x29): undefined reference to `tld::Trajectory::Trajectory()'
Main.cpp:(.text+0x3a): undefined reference to `imAcqGetImg(ImAcq*)'
Main.cpp:(.text+0x88): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
...
can anyone give me some idea what to do next?
Thanks.
=================
Thanks @ahendrix for helping me with the link problem. I should add the target_link_libraries
command.
But now it becomes:
[ 85%] Building CXX object tld/CMakeFiles/tld.dir/src/main/Trajectory.cpp.o
Linking CXX shared library /home/aqua/catkin/devel/lib/libtld.so
/usr/bin/ld: cannot find -llibopentld
/usr/bin/ld: cannot find -lcvblobs
I don't think I need to build the share library in the /usr/lib
since the original doesn't do that. It should also be a makefile problem.
The original is: include_directories(main ../libopentld/imacq ../libopentld/mftracker ../libopentld/tld ../3rdparty/cvblobs ${OpenCV_INCLUDE_DIRS})
add_library(main
main/Config.cpp
main/Gui.cpp
main/Main.cpp
what I did:
include_directories(tld
include/libopentld/imacq
include/libopentld/mftracker
include/libopentld/tld
include/3rdparty/cvblobs
${OpenCV_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS})
add_library(tld
src/main/Config.cpp
src/main/Gui.cpp
src/main/Main.cpp
src/main/Settings.cpp
what the original is:
target_link_libraries(main libopentld cvblobs config++ ${OpenCV_LIBS})
add_executable(opentld
OpenTLD.cpp)
target_link_libraries(opentld main libopentld cvblobs config++ ${OpenCV_LIBS})
what I did:
target_link_libraries(tld libopentld cvblobs config++ ${OpenCV_LIBS} ${catkin_LIBRARIES})
add_executable(opentld
src/OpenTLD.cpp)
target_link_libraries(opentld tld libopentld cvblobs config++ ${OpenCV_LIBS})
I believe there should be some issues here but I tried some code change but still get the error.
The cmake
target_link_libraries
command performs linking.Just for information, OpenTLD is old and the team now recommends CMT instead, http://www.gnebehay.com/cmt/ it is implemented in Python for now and integrating it in ROS goes straight-forward.
@ahendrix thanks! you are always awesome! now it shows ``` /usr/bin/ld: cannot find -llibopentld /usr/bin/ld: cannot find -lcvblobs ``` but I already add the path of libopentld and cvblobs into `include_directories` and they are not .so file so I cannot copy them into `/usr/lib` any suggestion?
thanks @Mehdi, I tested both of them and think the TLD performs better and run faster than the CMT. maybe that is the problem caused by the difference of c and python
Do you build these two libraries? Side note: Copying anything by hand to /usr/lib should never be your first solution.
@BennyRe I updated the question. I don't think I need to build that two libraries individually, they should be build when I make the package I think.
update: the owner of this ROS repo has catkinized this package. https://github.com/Ronan0912/ros_opentld