Ask Your Question
0

CMakeList.txts: transfer from cmake to catkin_make

asked 2014-08-04 21:33:55 -0500

updated 2014-08-05 00:55:31 -0500

Hi,

I'm trying to transfer the opentld program into ROS package.

What I'm trying now is

  1. init a catkin package
  2. copy the content of opentld into src folder of catkin package
  3. copy the folder 3rdparty and libopentld into include folder of catkin package
  4. modify the CMakeLists.txt file in catkin package according to the CMakeLists.txt of TLD program

    4.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.

edit retag flag offensive close merge delete

Comments

The cmake target_link_libraries command performs linking.

ahendrix gravatar imageahendrix ( 2014-08-04 21:39:01 -0500 )edit

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.

Mehdi. gravatar imageMehdi. ( 2014-08-04 21:55:22 -0500 )edit

@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?

lanyusea gravatar imagelanyusea ( 2014-08-04 21:56:51 -0500 )edit

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

lanyusea gravatar imagelanyusea ( 2014-08-04 21:58:21 -0500 )edit

Do you build these two libraries? Side note: Copying anything by hand to /usr/lib should never be your first solution.

BennyRe gravatar imageBennyRe ( 2014-08-04 23:45:58 -0500 )edit

@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.

lanyusea gravatar imagelanyusea ( 2014-08-05 00:44:50 -0500 )edit

update: the owner of this ROS repo has catkinized this package. https://github.com/Ronan0912/ros_opentld

lanyusea gravatar imagelanyusea ( 2014-08-10 21:47:22 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-08-05 01:37:20 -0500

ahendrix gravatar image

I think you should read through the existing cmake files again. Note that there are source files and cmake files in the 3rdparty and libopentld folders, and that they were originally included from the top-level cmake file.

I suspect the issues you're having are mostly because you aren't building the 3rdparty and opentld libraries the same way that the original project did.

edit flag offensive delete link more

Comments

and is there any possibility to make it as a ROS node although I cannot put it inside my catkin workspace?

lanyusea gravatar imagelanyusea ( 2014-08-05 02:44:43 -0500 )edit
1

catkin IS cmake. You should be able to re-use most of the existing package structure and build system as a catkin package.

ahendrix gravatar imageahendrix ( 2014-08-05 11:01:59 -0500 )edit
0

answered 2014-08-05 02:32:49 -0500

BennyRe gravatar image

updated 2014-08-05 02:54:32 -0500

@ahendrix is right. You have to build these libraries within your package.

See the openTLD CMakeList files here and here.

Add the add_library commands to your CMakeLists.txt or use sub CMakeLists.txt in this case you may even be able to simply copy the original CMakeLists.txts.

There the original openTLD project builds them.

edit flag offensive delete link more

Comments

thanks. I compiled the original project directly and got the library file cvblobs.a and libopentld.a; I copied them to /usr/lib directly (not sure if I can do this), then the cvblobs.a is found but there is still /usr/bin/ld: cannot find -llibopentld I will try more then give up, if still failed

lanyusea gravatar imagelanyusea ( 2014-08-05 02:48:05 -0500 )edit

Don't compile anything by hand and place it in /usr/lib. Build these libraries in your project. See my updated answer.

BennyRe gravatar imageBennyRe ( 2014-08-05 02:52:35 -0500 )edit

there is the add_library as what the original project does and I correct the path. and I think I need to use include_directories in order to specify the additional locations of header files

lanyusea gravatar imagelanyusea ( 2014-08-05 03:09:08 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-08-04 21:33:55 -0500

Seen: 1,124 times

Last updated: Aug 05 '14