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

How to write a library in ROS? [closed]

asked 2012-03-04 07:19:05 -0500

Hi, I am trying to write my own ros library. Just a ROS package containing a .hpp, a .cpp and the compiled library of the cpp.

I put the cpp inside the src folder, the hpp into the include directory and added the add_library command to the CMakeLists.txt, and the shared object file is created. But now I want to get this library used by another package. I added the library package to its manifest.xml. And it does not find the header file of the library package. I can make it link the library with multiple commands in the CMakeLists but then I still do not get the header file.

I found a tutorial on github: Tutorial

It says that something needs to be added to the manifest.xml, but unfortunately the line telling that is missing. (The line was removed because of the tags I guess)

I guessed it might be the <export> tag like this:
 <export>
    <cpp cflags="-I${prefix}/include/ -I${prefix}/include/NameOfLib" lflags="-L${prefix}/lib -Wl,-rpath,${prefix}/lib -lNameOfLib"/> 
  </export>

But it doesn't work.

Can anybody help me with that?

Thanks.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by kwc
close date 2012-03-05 18:59:23

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-03-04 11:26:05 -0500

Got it! Must be related to old compilation data, I am using the cmake extensions for Eclipse and I deleted CMakeCache.txt cmake_install.cmake and the directory CMakeFiles and recompiled everything, now it seems to work.

edit flag offensive delete link more
1

answered 2012-03-04 07:31:22 -0500

Kevin gravatar image

Did you also set set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) in your CMakeLists.txt?

Of course in the Manifest.xml file of the other package you want to use this library you add somethings like <depend package="NameOfLib"> so it goes and grabs that <export> tag.

edit flag offensive delete link more

Comments

I created the package with roscreate-pkg, so yes it's set. I also did the same with the other package referencing the library package in the manifest, but it still does not work.

cyborg-x1 gravatar image cyborg-x1  ( 2012-03-04 10:17:10 -0500 )edit

Question Tools

Stats

Asked: 2012-03-04 07:19:05 -0500

Seen: 354 times

Last updated: Mar 04 '12