- 创建工作空间
- 创建程序包
- 添加cpp程序
- 修改包中CMakeList.txt文件
- catkin_make
1.创建工作空间
$ source /opt/ros/kinetic/setup.bash
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace
$ cd ~/catkin_ws/
$ catkin_make
$ source devel/setup.bash
$ echo $ROS_PACKAGE_PATH
2.创建一个catkin程序包
$ cd ~/catkin_ws/src
$ catkin_create_pkg mypackage std_msgs rospy roscpp
$ cd ~/catkin_ws
$ catkin_make
$ . ~/catkin_ws/devel/setup.bash
3.添加cpp程序
4.修改包中CMakeList.txt文件
add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
5.catkin_make
$ cd ~/catkin_ws
$ catkin_make