Compilation make:$LD\u运行路径被忽略
我正在从源代码处编译FFmpegCompilation make:$LD\u运行路径被忽略,compilation,ffmpeg,makefile,ld,Compilation,Ffmpeg,Makefile,Ld,我正在从源代码处编译FFmpeg ./configure --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-x11grab --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-li
./configure --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-x11grab --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264
make
make install
ldd/usr/local/bin/ffmpeg
给了我这个
linux-gate.so.1 => (0xb7717000)
libavdevice.so.53 => not found
libavfilter.so.2 => not found
libavformat.so.54 => not found
libavcodec.so.54 => not found
libpostproc.so.52 => not found
libswresample.so.0 => not found
libswscale.so.2 => not found
libavutil.so.51 => not found
libm.so.6 => /lib/i386-linux-gnu/tls/i686/nosegneg/libm.so.6 (0xb76e3000)
libpthread.so.0 => /lib/i386-linux-gnu/tls/i686/nosegneg/libpthread.so.0 (0xb76ca000)
libc.so.6 => /lib/i386-linux-gnu/tls/i686/nosegneg/libc.so.6 (0xb7569000)
/lib/ld-linux.so.2 (0xb7718000)
将$LD_LIBRARY_PATH
设置为/usr/local/lib
更正了“未找到”错误,但出于上述原因,我不想永久设置$LD_LIBRARY_PATH
我使用相同的命令重新编译,这次将$LD\u RUN\u PATH
设置为/usr/local/lib
make
在编译时似乎忽略了$LD\u RUN\u PATH
有没有一种方法可以使用
$LD\u RUN\u PATH
,而无需对生成文件进行大量更改?您有没有理由在共享模式下编译二进制文件(比如想要构建软件来链接它们)?如果静态“ffmpeg”二进制文件同样适用于您,请在不使用--enable shared选项的情况下进行配置,以消除这些依赖关系
否则,您需要通过在环境中设置LD_LIBRARY_PATH、使用LD_LIBRARY_PATH(例如,“LD_LIBRARY_PATH=/usr/local/lib/usr/local/bin/ffmpeg”)预先执行“ffmpeg”,或使用正确的位置更新系统的库路径,让系统知道共享库的位置
在您在帖子中链接的页面底部还有一个解决方案:“LDFLAGS='-L/my/strange/path/lib-Wl,-rpath/my/strange/path/lib'”。对于FFmpeg和您的情况,请在配置时传递此额外参数:
--extra-ldflags="-L/usr/local/lib -Wl,-rpath /usr/local/lib"
得到的“ffmpeg”二进制文件将知道在哪里可以找到共享库
这个问题有很多解决方案。对于其他偶然发现这个问题的人来说,
$LD\u RUN\u PATH
不起作用的原因可能是由于黄金链接器
(解决方法是按照Mike的回答使用rpath)
你能用手成功链接(即在命令行上,不使用make)吗?我不知道。我如何测试它?您能给我们展示一下makefile中执行
ldd/usr/local/bin/ffmpeg
的部分吗?您是如何配置ffmpeg的(即,您向./configure脚本传递了哪些选项)?构建之后,您是如何安装FFmpeg的;您是否手动将“ffmpeg”复制到/usr/local/lib?或者您是否执行了“make install”?检查变量LD\u DEBUG
和LD\u DEBUG\u OUTPUT
。我不知道是否需要共享选项,但这是指令使用的。--extra-ldflags
工作正常。