Compile roscpp without ros (using g++)

女生的网名这么多〃 提交于 2019-12-31 02:29:07

问题


I'm trying to compile roscpp without using the rest of ROS (I only need to subscribe to a node but the one that own that uses an old version of ROS and I couldn't integrate my program with his due to compilation troubles). I downloaded the source code from git (https://github.com/ros/ros_comm) and now I need to compile it, but Cmake throw me errors:

 INFOBuilding GTest from source.
 TODO: implement add_roslaunch_check() in rostest-extras.cmake.
 CMake Error at CMakeLists.txt:8 (catkin_package_xml):
     Unknown CMake command "catkin_package_xml".

How can I build it? I'm calling cmake CMakeList.txt, but it doesn't work.


回答1:


I suggest you to use rosinstall_generator to compile the package you want, such as roscpp. Here are the steps:

Download the package and its dependencies:

rosinstall_generator roscpp --rosdistro <ROS_Distro that you use> --deps > roscpp_ros.rosinstall
wstool init src roscpp_ros.rosinstall -j8
rosdep install --from-path src -i -y

Then compile it:

src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release

The compiled packages will be in the folder install_isolated (at the same level as the folder src)




回答2:


Use this command line to compile your code directly with g++:

g++ yourtest.cpp -o yourtest -I/opt/ros/indigo/include -L/opt/ros/indigo/lib \
-Wl,-rpath,/opt/ros/indigo/lib -lroscpp -lrosconsole -lrostime \
-lroscpp_serialization -lboost_system -lboost_thread -pthread -lactionlib

Where yourtest.cpp is your c++ file that has some ros code.

If you are using a ros version different of the indigo replace de indigo string by the string of your version.



来源:https://stackoverflow.com/questions/28669349/compile-roscpp-without-ros-using-g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!