开发者社区> 问答> 正文

FFmpeg库简单使用,编译不过。求指点?报错

  1. 系统环境:virtualbox + ubuntukylin-16.04 32位
  2. 编译环境:已按ffmpeg官方文档下载源码并一步步编译成功,库文件和头文件都放到了/usr/local目录下
  3. 使用测试:

代码:

#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!

 

    展开
    收起
    爱吃鱼的程序员 2020-06-08 11:29:03 1548 0
    1 条回答
    写回答
    取消 提交回答
    • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

      有问题找我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库调用测试,没有报错。

      编译是基本功啊求人太丢人了.

      2020-06-08 11:29:19
      赞同 展开评论 打赏
    问答分类:
    问答地址:
    问答排行榜
    最热
    最新

    相关电子书

    更多
    Python系列直播第一讲——Python中的一切皆对象 立即下载
    Python 脚本速查手册 立即下载
    低代码开发师(初级)实战教程 立即下载