[ 12%] Building CXX object usb_cam/CMakeFiles/v4l_driver.dir/src/camera_driver.cpp.o /root/catkin_uc/src/usb_cam/src/camera_driver.cpp: In destructor ‘virtual usb_cam::AbstractV4LUSBCam::~AbstractV4LUSBCam()’: /root/catkin_uc/src/usb_cam/src/camera_driver.cpp:239:5: error: ‘av_packet_free’ was not declared in this scope av_packet_free(&avpkt); ^~~~~~~~~~~~~~ /root/catkin_uc/src/usb_cam/src/camera_driver.cpp:239:5: note: suggested alternative: ‘av_packet_ref’ av_packet_free(&avpkt); ^~~~~~~~~~~~~~ av_packet_ref /root/catkin_uc/src/usb_cam/src/camera_driver.cpp: In static member function ‘static bool usb_cam::AbstractV4LUSBCam::init_decoder()’: /root/catkin_uc/src/usb_cam/src/camera_driver.cpp:379:13: error: ‘av_packet_alloc’ was not declared in this scope avpkt = av_packet_alloc(); ^~~~~~~~~~~~~~~ /root/catkin_uc/src/usb_cam/src/camera_driver.cpp:379:13: note: suggested alternative: ‘av_image_alloc’ avpkt = av_packet_alloc(); ^~~~~~~~~~~~~~~ av_image_alloc /root/catkin_uc/src/usb_cam/src/camera_driver.cpp: In static member function ‘static bool usb_cam::AbstractV4LUSBCam::decode_ffmpeg(const void*, int, usb_cam::camera_image_t*)’: /root/catkin_uc/src/usb_cam/src/camera_driver.cpp:779:8: error: ‘avcodec_send_packet’ was not declared in this scope if(avcodec_send_packet(avcodec_context, avpkt) < 0) ^~~~~~~~~~~~~~~~~~~ /root/catkin_uc/src/usb_cam/src/camera_driver.cpp:779:8: note: suggested alternative: ‘av_append_packet’ if(avcodec_send_packet(avcodec_context, avpkt) < 0) ^~~~~~~~~~~~~~~~~~~ av_append_packet /root/catkin_uc/src/usb_cam/src/camera_driver.cpp:792:9: error: ‘avcodec_receive_frame’ was not declared in this scope if (avcodec_receive_frame(avcodec_context, avframe_camera) < 0) ^~~~~~~~~~~~~~~~~~~~~ /root/catkin_uc/src/usb_cam/src/camera_driver.cpp:792:9: note: suggested alternative: ‘avcodec_free_frame’ if (avcodec_receive_frame(avcodec_context, avframe_camera) < 0) ^~~~~~~~~~~~~~~~~~~~~ avcodec_free_frame usb_cam/CMakeFiles/v4l_driver.dir/build.make:110: recipe for target 'usb_cam/CMakeFiles/v4l_driver.dir/src/camera_driver.cpp.o' failed make[2]: *** [usb_cam/CMakeFiles/v4l_driver.dir/src/camera_driver.cpp.o] Error 1 CMakeFiles/Makefile2:656: recipe for target 'usb_cam/CMakeFiles/v4l_driver.dir/all' failed make[1]: *** [usb_cam/CMakeFiles/v4l_driver.dir/all] Error 2 Makefile:140: recipe for target 'all' failed make: *** [all] Error 2 Invoking "make -j4 -l4" failed
时间: 2023-08-28 16:58:16 浏览: 191
根据您提供的错误信息,看起来编译过程中发生了一些与FFmpeg相关的问题。错误信息指出了一些FFmpeg函数未声明的错误。
从错误信息中可以看到以下几个函数未声明的错误:
- `av_packet_free` => 建议使用 `av_packet_unref`
- `av_packet_alloc` => 建议使用 `av_packet_alloc`
- `avcodec_send_packet` => 建议使用 `avcodec_send_packet`
- `avcodec_receive_frame` => 建议使用 `avcodec_receive_frame`
这些错误可能是由于FFmpeg版本不兼容或配置问题导致的。
解决这些错误的方法是:
1. 确保已正确安装FFmpeg库,以及头文件和库文件的路径设置正确。
2. 检查代码中是否有使用正确的FFmpeg函数名称。
3. 确保您的代码与所使用的FFmpeg版本兼容。
如果您是在ROS工作空间中进行编译,可以尝试以下步骤:
1. 确保已正确安装FFmpeg和相关的开发包。可以尝试通过命令 `apt-get install ffmpeg` 或 `apt-get install libavcodec-dev libavformat-dev libswscale-dev` 安装所需的包。
2. 在您的ROS工作空间的`CMakeLists.txt`文件中添加以下行:
```cmake
find_package(FFmpeg REQUIRED)
include_directories(${FFMPEG_INCLUDE_DIRS})
target_link_libraries(your_package_name ${FFMPEG_LIBRARIES})
```
将 `your_package_name` 替换为您的软件包名称。
3. 重新编译并检查是否仍然存在错误。
如果问题仍然存在,请确保您的代码中使用的FFmpeg函数与所安装的FFmpeg版本兼容,或者尝试升级您的FFmpeg版本。
如果上述方法无法解决问题,请提供更多关于您的编译环境和代码的详细信息,以便更好地帮助您解决问题。
阅读全文