一、错误:
undefined reference to `avformat_close_input(AVFormatContext**)'
undefined reference to `avformat_network_init()'
undefined reference to `av_dict_set(AVDictionary**, char const*, char const*, int)'
undefined reference to `avformat_find_stream_info(AVFormatContext*, AVDictionary**)'
undefined reference to `av_packet_unref(AVPacket*)'
二、检查 target_link_libraries:
target_link_libraries(main ascendcl acl_dvpp
InferBase ascendbasedevice
mosquitto protobuf
crypto chipeaksecure
opencv_core opencv_highgui opencv_imgcodecs opencv_imgproc opencv_videoio
${FFMPEG_LIBRARIES}
pthread -Wl,-z,relro,-z,now,-z,noexecstack -pie -s)
三、打印依赖库变量:${FFMPEG_LIBRARIES},发现变量是空的。
152 message("xxxxxxxFFFMPEG ${FFMPEG_LIBRARIES}")
153
154
155
156 target_link_libraries(main ascendcl acl_dvpp
157 InferBase ascendbasedevice
158 mosquitto protobuf
159 crypto chipeaksecure
160 opencv_core opencv_highgui opencv_imgcodecs opencv_imgproc opencv_videoio
161 ${FFMPEG_LIBRARIES}
162 # avcodec avformat avutil swscale pthread m swresample x264
163 pthread -Wl,-z,relro,-z,now,-z,noexecstack -pie -s)
四、检查发现 FFMPEG_PATH 路径出了问题:
#export FFMPEG_PATH=/opt/data/res/ffmpeg/
export FFMPEG_PATH=/opt/data/25-manager/res/ffmpeg/
五,修正,正常找到了依赖文件:
xxxxxxxFFFMPEG /opt/data/25-manager/res/ffmpeg/lib/libavcodec.so;/opt/data/25-manager/res/ffmpeg/lib/libavdevice.so;/opt/data/25-manager/res/ffmpeg/lib/libavfilter.so;/opt/data/25-manager/res/ffmpeg/lib/libavformat.so;/opt/data/25-manager/res/ffmpeg/lib/libavutil.so;/opt/data/25-manager/res/ffmpeg/lib/libswscale.so;/opt/data/25-manager/res/ffmpeg/lib/libswresample.so
六、link 顺利通过,yeah !!!
七、补充头文件配置:
#ifdef __cplusplus
extern "C" {
#endif
#include "libavformat/avformat.h"
#ifdef __cplusplus
}
#endif