4
回答
FFmpeg库简单使用,编译不过。求指点
注册华为云得mate10,2.9折抢先购!>>>   
  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!

 

举报
Yo狐狸大人
发帖于6个月前 4回/161阅
#if HAVE_VAAPI_X11
#   include <va/va_x11.h>
#endif
#if HAVE_VAAPI_X11
    if (!display && !(device && device[0] == '/')) {
        // Try to open the device as an X11 display.
        priv->x11_display = XOpenDisplay(device);
        if (!priv->x11_display) {
            av_log(ctx, AV_LOG_VERBOSE, "Cannot open X11 display "
                   "%s.\n", XDisplayName(device));
        } else {
            display = vaGetDisplay(priv->x11_display);
            if (!display) {
                av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display "
                       "from X11 display %s.\n", XDisplayName(device));
                return AVERROR_UNKNOWN;
            }

            av_log(ctx, AV_LOG_VERBOSE, "Opened VA display via "
                   "X11 display %s.\n", XDisplayName(device));
        }
    }
#endif

你看下X11的这个库是不是链接有问题。

--- 共有 1 条评论 ---
Yo狐狸大人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库调用测试,没有报错。 6个月前 回复
顶部