エラー:「(」トークンPLUGINLIB_DECLARE_CLASの前にコンストラクタ、デストラクタ、または型変換が必要です



Error Expected Constructor



コンパイルエラー:

/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

画像
エラーの理由は、pluginlulibライブラリ関数がubuntu18.04rosメロディーバージョンとubuntu16.04rosキネティックバージョンで変更されたためです。
解決:
以前の変更されていないコード:
画像
修正:



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

成功するために再度コンパイルする