我如何在运行时摆脱LD_LIBRARY_PATH? [英] How do I get rid of LD_LIBRARY_PATH at run-time?

查看:547
本文介绍了我如何在运行时摆脱LD_LIBRARY_PATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个使用英特尔的 IPP 库的C ++应用程序。这个库默认安装在/ opt中,并且需要你设置 LD_LIBRARY_PATH 来编译和运行你的软件(如果你选择共享库链接,我这样做了)。我已经修改了我的 configure.ac / Makefile.am ,这样在编译时我不需要设置该变量,但我仍然无法在运行时找到共享库;我该怎么做?



我正在编译 -Wl,-R / path / to / libdir flag使用 g ++



更新1
其实我的二进制程序有一些IPP库正确链接,但只有一个不是:

  $ ldd myprogram 
linux-vdso.so。 1 => (0x00007fffa93ff000)
libippacem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippacem64t.so.6.0(0x00007f22c2fa3000)
libippsem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippsem64t.so.6.0(0x00007f22c2d20000)
libippcoreem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippcoreem64t.so.6.0(0x00007f22c2c14000)
[...]
libiomp5.so =>未找到
libiomp5.so =>未找到
libiomp5.so =>找不到

当然这个图书馆在那里:

  $ locate libiomp5.so 
/opt/intel/ipp/6.0.2.076/em64t/sharedlib/libiomp5.so
正如Richard Pennington所建议的那样,我的应用程序并不直接使用缺失的库,但它被使用我使用的共享库。由于我无法重新编译IPP,因此解决我的问题的方法是在编译时添加 -liomp5 ,并使用连接器的-R选项。这实际上增加了libiomp5.so的rpath来解决这个问题!


I am building a C++ application that uses Intel's IPP library. This library is installed by default in /opt and requires you to set LD_LIBRARY_PATH both for compiling and for running your software (if you choose the shared library linking, which I did). I already modified my configure.ac/Makefile.am so that I do not need to set that variable when compiling, but I still can't find the shared library at run-time; how do I do that?

I'm compiling with the -Wl, -R/path/to/libdir flag using g++

Update 1: Actually my binary program has some IPP libraries correctly linked, but just one is not:

$ ldd myprogram
linux-vdso.so.1 =>  (0x00007fffa93ff000)
libippacem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippacem64t.so.6.0 (0x00007f22c2fa3000)
libippsem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippsem64t.so.6.0 (0x00007f22c2d20000)
libippcoreem64t.so.6.0 => /opt/intel/ipp/6.0.2.076/em64t/sharedlib/libippcoreem64t.so.6.0 (0x00007f22c2c14000)
[...]
libiomp5.so => not found
libiomp5.so => not found
libiomp5.so => not found

Of course the library is there:

$ locate libiomp5.so
/opt/intel/ipp/6.0.2.076/em64t/sharedlib/libiomp5.so

解决方案

As suggested by Richard Pennington, the missing library is not used directly by my application, but it is used by the shared libraries I use. Since I cannot recompile IPP, the solution to my problem is to add -liomp5 when compiling, using the -R option for the linker. This actually adds the rpath for libiomp5.so fixing the problem!

这篇关于我如何在运行时摆脱LD_LIBRARY_PATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆