代码:
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavutil/avutil.h"
#include "stdio.h"
int main(int argc, char* argv[])
{
printf("going to av_register_all\n");
av_register_all();
return 0;
}
编译:
gcc -o ffmpeg_test ffmpeg_test.c -lavformat -lavcodec -lavutil -lz -lm -lpthread
编译报错:
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vdpau.c:431: undefined reference to `XOpenDisplay'
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vdpau.c:437: undefined reference to `XDisplayString'
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vdpau.c:439: undefined reference to `XDefaultScreen'
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vdpau.c:439: undefined reference to `vdp_device_create_x11'
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vdpau.c:433: undefined reference to `XDisplayName'
//usr/local/lib/libavutil.a(hwcontext_vdpau.o): In function `vdpau_device_free':
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vdpau.c:410: undefined reference to `XCloseDisplay'
collect2: error: ld returned 1 exit status
添加 -lX11,继续报错:
/usr/bin/ld: //usr/local/lib/libavcodec.a(cuvid.o): undefined reference to symbol 'dlopen@@GLIBC_2.1'
//lib/i386-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
网上搜索尝试添加 -ldl,继续报错:
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vaapi.c:945: undefined reference to `vaGetDisplay'
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vaapi.c:990: undefined reference to `vaInitialize'
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vaapi.c:969: undefined reference to `vaGetDisplayDRM'
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vaapi.c:992: undefined reference to `vaErrorStr'
//usr/local/lib/libavutil.a(hwcontext_vdpau.o): In function `vdpau_device_create':
/home/zane/Documents/FFmpeg-master/libavutil/hwcontext_vdpau.c:439: undefined reference to `vdp_device_create_x11'
collect2: error: ld returned 1 exit status
每次都有很多undefined reference to的错误,搜索很久也没有找到解决办法,
求各路大神施展援手,感谢感谢。为你打call!
有问题找我364953305秋秋
#ifHAVE_VAAPI_X11#include<va/va_x11.h>#endif
#ifHAVE_VAAPI_X11if(!display&&!(device&&device[0]=='/')){//TrytoopenthedeviceasanX11display.priv->x11_display=XOpenDisplay(device);if(!priv->x11_display){av_log(ctx,AV_LOG_VERBOSE,"CannotopenX11display""%s.\n",XDisplayName(device));}else{display=vaGetDisplay(priv->x11_display);if(!display){av_log(ctx,AV_LOG_ERROR,"CannotopenaVAdisplay""fromX11display%s.\n",XDisplayName(device));returnAVERROR_UNKNOWN;}av_log(ctx,AV_LOG_VERBOSE,"OpenedVAdisplayvia""X11display%s.\n",XDisplayName(device));}}#endif
你看下X11的这个库是不是链接有问题。
X11的库:/usr/lib/i386-linux-gnu/libX11.a/usr/lib/i386-linux-gnu/libX11.so/usr/lib/i386-linux-gnu/libX11.so.6/usr/lib/i386-linux-gnu/libX11.so.6.3.0另外做了简单X11库调用测试,没有报错。编译是基本功啊求人太丢人了.
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。