Ask Your Question

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

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

jlo gravatar image

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

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)
target_link_libraries(${GIMUtils} ../../../../lib/libGIMutils.a)
target_link_libraries(${MaCI} ../../../../lib/libMaCI.a)    
target_link_libraries(${GIMI} ../../../../lib/libGIMI.a)

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


edit retag flag offensive close merge delete


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 -0500 )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 -0500 )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 -0500 )edit
The link :'D (what's up with the character limit?)
jlo gravatar image jlo  ( 2012-02-09 22:55:38 -0500 )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 -0500 )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 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

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

Mani gravatar image

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

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


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


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

Seen: 5,137 times

Last updated: Sep 30 '12