Building CXX object CMakeFiles/usb_cam.dir/src/usb_cam.cpp.o /home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp: In static member function ‘static void usb_cam::UsbCam::frame_timer_callback(const ros::TimerEvent&)’: /home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp:306:24: error: ‘make_unique’ is not a member of ‘std’ auto ci = std::make_unique<sensor_msgs::CameraInfo>(camera_info->getCameraInfo()); ^~~~~~~~~~~ /home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp:306:24: note: suggested alternative: ‘__unique’ auto ci = std::make_unique<sensor_msgs::CameraInfo>(camera_info->getCameraInfo()); ^~~~~~~~~~~ __unique /home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp:306:59: error: expected primary-expression before ‘>’ token auto ci = std::make_unique<sensor_msgs::CameraInfo>(camera_info->getCameraInfo()); ^ CMakeFiles/usb_cam.dir/build.make:62: recipe for target 'CMakeFiles/usb_cam.dir/src/usb_cam.cpp.o' failed make[2]: *** [CMakeFiles/usb_cam.dir/src/usb_cam.cpp.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/usb_cam.dir/all' failed make[1]: *** [CMakeFiles/usb_cam.dir/all] Error 2 Makefile:140: recipe for target 'all' failed make: *** [all] Error 2
时间: 2024-03-23 13:43:33 浏览: 145
Cppcheck1.54C/C++静态代码分析工具
这是一个编译错误,它指出在文件`/home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp`的第306行中,`std`命名空间中不存在`make_unique`,它建议使用`__unique`作为替代。
这通常是因为编译器版本较旧导致的问题。`make_unique`是C++11中引入的智能指针创建函数,因此您需要确保您使用的编译器支持C++11。
您可以尝试升级您的编译器版本,或者在编译选项中添加`-std=c++11`或更高版本的标志。如果您使用的是ROS,则可以在`CMakeLists.txt`文件中添加以下行来设置编译器标志:
```cmake
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
```
这将确保使用C++11的编译器选项来编译您的代码。
阅读全文