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 15:43:33 浏览: 33
这是一个编译错误,它指出在文件`/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的编译器选项来编译您的代码。
相关问题
opencv make过程中Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2.cpp.o卡住了
这种情况通常是由于编译器或者链接器出现了问题导致的。你可以尝试以下方法解决这个问题:
1. 清空缓存并重新编译:
```
make clean
make
```
2. 尝试重新安装 Opencv:
```
sudo apt-get remove opencv
sudo apt-get install opencv
```
3. 检查你的编译器是否正常:
```
g++ --version
```
4. 检查你的链接器是否正常:
```
ld --version
```
如果以上方法都无法解决问题,你可以尝试在编译时添加 `-v` 参数,查看编译过程中的详细信息,以便更精确定位问题所在。
[ 0%] Building CXX object er2weima/CMakeFiles/traj_pub.dir/src/traj_pub.cpp.o /home/ros/catkin_ctr/src/er2weima/src/traj_pub.cpp:2:10: fatal error: quadrotor_msgs/PositionCommand.h: 没有那个文件或目录 2 | #include <quadrotor_msgs/PositionCommand.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [er2weima/CMakeFiles/traj_pub.dir/build.make:63:er2weima/CMakeFiles/traj_pub.dir/src/traj_pub.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:1091:er2weima/CMakeFiles/traj_pub.dir/all] 错误 2 make: *** [Makefile:141:all] 错误 2 Invoking "make -j4 -l4" failed
这个错误是因为编译器无法找到 "quadrotor_msgs/PositionCommand.h" 头文件。这可能是因为您的ROS工作空间没有包含该头文件的路径。您可以尝试以下两个步骤来解决该问题:
1. 确认您的catkin工作空间中包含 "quadrotor_msgs" 包。如果没有,您需要将其添加到您的工作空间中。
2. 确认您的CMakeLists.txt文件已经正确配置,您需要在CMakeLists.txt中添加以下行:
```
find_package(catkin REQUIRED COMPONENTS quadrotor_msgs)
include_directories(${catkin_INCLUDE_DIRS})
```
这将告诉CMake在编译时查找 "quadrotor_msgs" 包,并将其包含在构建过程中。
如果您已经尝试了以上步骤仍然无法解决问题,那么可能是您的ROS依赖项未正确安装或配置,您可以尝试重新安装ROS和相关依赖项。