编译ffmpeg作为独立的二进制 [英] Compile ffmpeg as stand alone binary
问题描述
我试图将 ffmpeg
编译为独立的二进制文件(因为我想在AWS lambda中使用它)
I'm trying to compile ffmpeg
as a standalone binary (because I want to use it in AWS lambda)
我可以在编译的服务器上正常工作,但如果我复制二进制文件并从另一个服务器运行它,我会得到:
I can get things to work fine on the server where I'm compiling, but if I copy the binary and run it from another server, I get:
./ ffmpeg:加载共享库时出错:libvdpau.so.1:无法打开共享对象文件:无此类文件或目录
所以这听起来似乎没有做成二进制。从我读过的,我已经编译ffmpeg与标志 - 禁用共享
和 - enable-static
,我已经做了:
So it sounds like something didn't made it into the binary. From what I've read, I've to compile ffmpeg with the flags --disable-shared
and --enable-static
, which I've done:
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--bindir="$HOME/bin" \
--disable-shared \
--enable-static \
--enable-gpl \
--enable-libass \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libvpx \
--enable-libx264
PATH="$HOME/bin:$PATH" make
make install
make distclean
hash -r
有没有我缺少的东西?
推荐答案
static
和 - disable-shared
仅影响 libav *
二进制文件。它不会阻止链接器使用必要的共享对象文件。
--enable-static
and --disable-shared
only affect libav*
binaries. It doesn't prevent linker to use necessary shared object files.
对于纯静态库,这将是棘手和混乱。你必须构建你需要的每个静态库,然后尝试添加额外的ldflags来配置。
For a pure static lib, this is going to be tricky and mess. You have to build every static lib you need, then try to add additional ldflags to configure.
另一个替代方法是一些工具将那些libs / elfs /二进制文件打包成一个大的。其中一些列在此处:将共享库打包到精灵
Another alternative is some tools packing those libs/elfs/binaries into a big one. Some of them are listed here: Pack shared libraries into the elf
这篇关于编译ffmpeg作为独立的二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!