最近在学习ROS机器人操作系统,尝试自己新建node,发现编译始终不通过
贴出问题代码
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
chapter2_tutorials/CMakeFiles/example1_c.dir/build.make:113: recipe for target '/home/jier/dev/catkin_ws/devel/lib/chapter2_tutorials/example1_c' failed
make[2]: *** [/home/jier/dev/catkin_ws/devel/lib/chapter2_tutorials/example1_c] Error 1
CMakeFiles/Makefile2:915: recipe for target 'chapter2_tutorials/CMakeFiles/example1_c.dir/all' failed
make[1]: *** [chapter2_tutorials/CMakeFiles/example1_c.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
后来发现是个弱智错误,新建的example1_c.cpp文件里面没有写东西
解决方案:
1、删除空cpp文件
2、或者在cpp文件里写代码
重新编译即可通过