Building and linking ros library
Hi All,
I'm trying to rosbuild a library, which will then be included in several other ROS-packages. Right now, I have successfully created the library in "DeviceHandler" package by:
rosbuild_add_library(Advertiser src/Advertiser.cpp)
This library consists of a class (Advertiser.cpp and Advertiser.hpp) I have exported the following flags in the Manifest.xml of "DeviceHandler":
<export>
<cpp cflags="-I${prefix} -I${prefix}/include/ -I${prefix}/include/DeviceHandler/ -I${prefix}/msg_gen/cpp/include/DeviceHandler -I${prefix}/srv_gen/cpp/include/DeviceHandler" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lAdvertiser"/>
</export>
And I have made my new package (let's call it NewPackage) depend on this "DeviceHandler" package - which builds the "libAdvertiser.so".
So far so good, however, when I try to utilise the library (libAdvertiser.so) in the "NewPackage", it simply can't find "Advertiser.hpp" when included inside code.
Inside my main.cpp in "NewPackage" I have:
#include "Advertiser.hpp"
And the compiler fails on this one, with the output:
/home/casper/ros_workspace/MobileManipulator/hardware_reconfig_system/DeviceEmulators/src/GripperEmulator.cpp:26:26: fatal error: Advertiser.hpp: No such file or directory
The DeviceHandler package both builds the library + an executable, but is that the problem?
Also, should I do anything in the CMakeList.txt of "NewPackage" in order to link the library?
I have been searching for a couple of hours for an answer and nothing really seemed to do the trick. Hoping that it is just some detail I'm missing, any help is much appreciated.
Thanks /Casper
Copy the compile errors that you get in your question and also add the code that doesn't compile.
Hi, sure, that should be in there now...
And where is the file in the package?
Well, the Advertiser.hpp is not in the "NewPackage". Is is in the shared object "libAdvertiser.so" created by the "DeviceHandler" package. So, the Advertiser.hpp is in /DeviceHandler/src/Advertiser.hpp.. Shouldn't I be able to access the headerfile used in a shared object? I should note, that this library stuff is a bit new to me...