c - 编译某些 ffmpeg 应用程序时出现 gcc 奇怪的 ld 错误,找不到 libvorbisenc 包

标签 c linux gcc ffmpeg

我关注ffmpeg tuorial , 并通过 ppa 安装 ffmpeg

但是当我编译tuorial02.c时,出现gcc错误:

/usr/bin/ld: /opt/ffmpeg/lib//libavcodec.a(libvorbisenc.o): undefined reference to symbol 'vorbis_encode_setup_vbr'

//usr/lib/x86_64-linux-gnu/libvorbisenc.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

我的编译命令是:

gcc -I /opt/ffmpeg/include/ -L /opt/ffmpeg/lib/  -o tutorial02 tutorial02.c -lavformat -lavcodec -lswscale `sdl-config --cflags --libs`  -lpthread -lz -lm -ldl

我找了几个小时的原因。我无法解决这个问题。谁能帮帮我?

已添加 我已将 -lvorbisenc 添加到末尾。错误是找不到库。并且 libvorivisenc2 已经安装。所以这个问题不是Strange linking error: DSO missing from command line的重复

我的操作系统是 Linux mint 17.3

最佳答案

错误告诉您静态库 libavcodec.a 引用了 libvorbisenc 中的符号,但 libvorbisenc 并未在您的链接命令中明确显示(尽管它确实从链接命令)。您需要将 -lvorbisenc$(pkg-config --libs vorbisenc) 显式添加到您的命令行。

(旧版本的 binutils 允许您在这种情况下隐式引入共享库;但是,新版本的 binutils 更严格。)

关于c - 编译某些 ffmpeg 应用程序时出现 gcc 奇怪的 ld 错误,找不到 libvorbisenc 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37096129/

相关文章:

Linux 终端快捷键

c - C/GCC 4.6.3 中的 union 填充值

c - 我是否应该针对 I/O 应用程序的大小 (-Os) 进行优化

c++ - "is private within this context"被抛出用于不应该是私有(private)的函数(GCC 5.3.0,C++11)

c - 用 C 实现 2D 网格网络(图)及其邻接矩阵

c - 在 C 中传递、编辑和返回变量

c - C中的for循环显示2的前30次方?

c - 想要询问用户他们想要在 C 中扫描什么文件

linux - 问题 : Decoding a file on linux machine from command line

ruby - nginx配置有什么问题?