error: expected constructor, destructor, or type conversion before ‘(’ token PLUGINLIB_DECLARE_CLAS

编译错误:

/home/star/rikirobot/catkin_ws/src/depth_camera/depthimage_to_laserscan/src/DepthImageToLaserScanNodelet.cpp:60:24: error: expected constructor, destructor, or type conversion before ‘(’ token
 PLUGINLIB_DECLARE_CLASS(depthimage_to_laserscan, DepthImageToLaserScanNodelet, depthimage_to_laserscan::DepthImageToLaserScanNodelet, nodelet::Nodelet);
                        ^
depth_camera/depthimage_to_laserscan/CMakeFiles/DepthImageToLaserScanNodelet.dir/build.make:62: recipe for target 'depth_camera/depthimage_to_laserscan/CMakeFiles/DepthImageToLaserScanNodelet.dir/src/DepthImageToLaserScanNodelet.cpp.o' failed
make[2]: *** [depth_camera/depthimage_to_laserscan/CMakeFiles/DepthImageToLaserScanNodelet.dir/src/DepthImageToLaserScanNodelet.cpp.o] Error 1
CMakeFiles/Makefile2:6307: recipe for target 'depth_camera/depthimage_to_laserscan/CMakeFiles/DepthImageToLaserScanNodelet.dir/all' failed
make[1]: *** [depth_camera/depthimage_to_laserscan/CMakeFiles/DepthImageToLaserScanNodelet.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j1" failed

error: expected constructor, destructor, or type conversion before ‘(’ token PLUGINLIB_DECLARE_CLAS_第1张图片
出现错误的原因是ubuntu18.04 ros melodic版本与ubuntu16.04 ros kinetic版本中,pluginlib库函数发生了变化。
解决方法:
未修改前的代码:

修改为:

PLUGINLIB_EXPORT_CLASS(depthimage_to_laserscan::DepthImageToLaserScanNodelet, nodelet::Nodelet)

再次编译,即可成功

你可能感兴趣的:(Debug错误集锦,ubuntu,linux,cmake)