ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to include my own libraries in cmake to compile with rosmake?

asked 2012-02-07 23:37:11 -0600

jlo gravatar image

updated 2014-01-28 17:11:18 -0600

ngrennan gravatar image

Hi there, I am working in a thesis where I have to use ROS within a system (and the other way round). So far, what I have changed in the CMakeLists.txt is including the following lines:

rosbuild_add_executable(ROSPublisher2MaCIClient ROSPublisher2MaCIClient.cpp)
include_directories(../../../../include/utils)
target_link_libraries(${GIMUtils} ../../../../lib/libGIMutils.a)
include_directories(../../../../include/MaCI)
target_link_libraries(${MaCI} ../../../../lib/libMaCI.a)    
include_directories(../../../../include/GIMI)
include_directories(../../../../include/GIMnetAP)
include_directories(../../../../include)
target_link_libraries(${GIMI} ../../../../lib/libGIMI.a)
include_directories(/usr/include/libxml2)
TARGET_LINK_LIBRARIES(xml2)
add_definitions(-DLINUX_OS)

But there's no way it's working. I get a lot of "undefined reference" errors and I don't have an idea of how to fix it. That's why I was wondering: Is this the way to do it? (at least, so far the lines I have included in the CMakeLists.txt or is there something I'm missing (or some other file I have to update to make it all work with rosmake).

Cheers,

edit retag flag offensive close merge delete

Comments

You are using some variables (MaCI, etc.) that nobody knows how they are defined and you are referring to some paths in your system that we do not know. Also nobody here know what libraries need to be linked/build for your project. Without this information it is impossible to answer that question.
dornhege gravatar image dornhege  ( 2012-02-07 23:50:58 -0600 )edit
Sorry if it seemed a like bit of an obtuse question, my intention was to see if the syntax was right to include libraries. Then again, it will be probably better to ask it in a cmake forum. In any case, this is all I know, I need to include this path "../../../../lib/" (I checked) and the libraries
jlo gravatar image jlo  ( 2012-02-09 22:52:39 -0600 )edit
MaCI, GIM, GIMI and GIMutils. I would love to tell you more about these systems, but I know almost as much of them as you guys do. If anyone it's interested to take a look into MaCI, here's a link: It's in a way a state-of-the-art take on what ROS is for, used for remote controlled machinery, f.i.
jlo gravatar image jlo  ( 2012-02-09 22:55:07 -0600 )edit
The link http://gim.tkk.fi/MaCI :'D (what's up with the character limit?)
jlo gravatar image jlo  ( 2012-02-09 22:55:38 -0600 )edit
THere is the link_directories command, that might do something useful for what you want.
dornhege gravatar image dornhege  ( 2012-02-10 06:51:23 -0600 )edit

@jlo The character limit is to encourage most information to be in the question and in a curated answer. Usually it's recommended for the original poster to update their question instead of replying in the comments. .

tfoote gravatar image tfoote  ( 2012-03-14 12:22:44 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-09-30 12:02:40 -0600

Mani gravatar image

updated 2012-09-30 12:05:02 -0600

In this ROS driver there is a dependency on some other libraries similar to your project. The package's CMakeList.txt might be a working example of what you need.

Update: This answer to a similar question might also be helpful.

edit flag offensive delete link more

Comments

Those examples should help. You're using target_link_libraries incorrectly, the first argument should be the cmake target name to which you want to link. I'd expect ROSPublisher2MaCIClient in this case.

tfoote gravatar image tfoote  ( 2012-10-14 17:36:45 -0600 )edit

Question Tools

Stats

Asked: 2012-02-07 23:37:11 -0600

Seen: 5,259 times

Last updated: Sep 30 '12