4
回答
FFmpeg库简单使用,编译不过。求指点
开发十年,就只剩下这套Java开发体系了   
  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狐狸大人
发帖于1年前 4回/869阅
顶部