Including ros into scons project
Hi,
I have built ros from sources (specifically ros2 bouncy bolson). The result is that I have a workspace containing all the header and lib files.
Now I would like to write a ros node inside a project which is built using Scons. How should I include and link properly all the required stuffs?
My program is just an hello world which includes the C++ client library
#include <iostream>
#include "rclcpp/rclcpp.hpp"
int main(int argc, char* argv[])
{
std::cout<<"Hello World!"<<std::endl;
return 0;
}
Sconstruct file
env = Environment()
env.Append(CXXFLAGS = ['-std=c++14'])
env.Append(CPPPATH = ['<PATH_TO_ROS2_WS>/install/rclcpp/include', .....])
env.Append(LIB_PATH=['<PATH_TO_ROS2_WS>/install/rclcpp/lib', ....])
env.Program("hello_ros", ["hello_ros.cpp"])
I tried to manually append one by one to the environment the path to ROS2 include dirs and library locations.
UPDATE: I was getting an error due to the CXXFLAGS set to c++11, ROS2 requires C++14.
Is there a way to let Scons find the ROS2 include and library files, instead of having to manually specify them (they are a lot if I'm not using the --merge-install flag during the ros2 build)?
Thanks
When you say nothing is working, can you paste the error message? I guess it is a linkage error but maybe it is something different. You will need to include all libraries/includes from ROS2 (at least the one that RCLCPP depends on).
Hi, thanks for your help but I solved that error. I have still an issue due to the fact that I have to manually specify all the lib and include paths (they are a lot if I'm not using the --merge-install flag during the ros2 build)
I don't think there is another solution to adding all the lib/include paths to your build. (unfortunately :D)