如何配置链接以便编译的二进制文件找到库?

时间:2015-10-05 08:21:46

标签: linux compilation ffmpeg makefile

我正在编译ffmpeg。配置:

--prefix=/home/john/zope/engage/zeocluster/ffmpeg/parts/ffmpeg-build --extra-cflags='-I/home/john/zope/engage/zeocluster/ffmpeg/parts/x264-build/include -I/home/john/zope/engage/zeocluster/ffmpeg/parts/ogg-build/include -I/home/john/zope/engage/zeocluster/ffmpeg/parts/theora-build/include -I/home/john/zope/engage/zeocluster/ffmpeg/parts/lame-build/include -I/home/john/zope/engage/zeocluster/ffmpeg/parts/faac-build/include -I/home/john/zope/engage/zeocluster/ffmpeg/parts/faad-build/include -I/home/john/zope/engage/zeocluster/ffmpeg/parts/vpx-build/include -I/home/john/zope/engage/zeocluster/ffmpeg/parts/vorbis-build/include -I/home/john/zope/engage/zeocluster/ffmpeg/parts/ffmpeg-build/include' --extra-ldflags='-L/home/john/zope/engage/zeocluster/ffmpeg/parts/x264-build/lib -L/home/john/zope/engage/zeocluster/ffmpeg/parts/ogg-build/lib -L/home/john/zope/engage/zeocluster/ffmpeg/parts/theora-build/lib -L/home/john/zope/engage/zeocluster/ffmpeg/parts/lame-build/lib -L/home/john/zope/engage/zeocluster/ffmpeg/parts/faac-build/lib -L/home/john/zope/engage/zeocluster/ffmpeg/parts/faad-build/lib -L/home/john/zope/engage/zeocluster/ffmpeg/parts/vpx-build/lib -L/home/john/zope/engage/zeocluster/ffmpeg/parts/vorbis-build/lib -L/home/john/zope/engage/zeocluster/ffmpeg/parts/ffmpeg-build/lib'

构建完成正常,LD_LIBRARY_PATH=./parts/ffmpeg-build/lib:./parts/x264-build/lib ./parts/ffmpeg-build/bin/ffmpeg运行二进制文件。

为什么需要LD_LIBRARY_PATH?我没有告诉编译器链接这些库吗?

1 个答案:

答案 0 :(得分:2)

如果您正在使用gcc,则可以使用链接器选项在运行时指定动态链接的首选路径。您可以添加多个rpath选项,每个选项都是这样的:

gcc ... -Wl,-rpath=<PATH>