ron*_*ron 13 libraries gcc ldconfig ld.so.conf
我经常从源代码构建各种库以供使用,例如 gmp-6.1.2、mpfr-4.0.1 和 gcc-7.x。这样做时,我更喜欢使用,--prefix=/usr/local/gcc-7.2.0所以我确切地知道它的安装位置并且不会弄乱现有的库。然后我基本上只知道最后make install告诉我的是更新或设置LD_LIBRARY_PATH,有时但不总是LD_RUN_PATH。
大多数情况下,我只是LD_LIBRARY_PATH稍后根据需要手动设置,或者以类似的方式全局设置它/etc/bash.bashrc.local并且有效。
这make install就是说:
Libraries have been installed in:
/usr/local/mfprtest/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法,或者更官方的方法?使用ldconfig and ld.so.conf比使用LD_LIBRARY_PATH和LD_RUN_PATH,和PATH?这是专门用于编写我自己的代码,但也可能适用于其他用户,在这些用户中,我想链接库的各种较新版本,而不是使用给定的 linux 版本(例如 gmp、mpfr)安装的库,然后使用各种手动安装的版本gcc 的,例如 gcc-5.x 或 gcc-6.x 或 gcc-7.x。
基本上,/usr/local/gcc-7.3.0例如,一旦我安装,我希望我自己和任何其他在系统上编写或运行自产的 c、c++ 或 fortran 源代码的用户使用,/usr/local/gcc-7.3.0而不是 /usr/bin/ 和 /usr/ 中的系统版本库64/
解决方案是将您的库目录添加/usr/local/gcc-7.3.0/lib/到/etc/ld.so.conf(或 中的文件/etc/ld.so.conf.d/)并运行ldconfig或更改用户的 shell 配置文件以覆盖系统的LD_LIBRARY_PATH/LD_RUN_PATH并添加单独的*/lib条目,以便链接器可以找到共享对象。
一旦开始添加库,维护的复杂性就会增加,因此请记住这一点。
您的另一个选择是链接 中的所有文件/usr/local/<library>/{bin,lib,include} into /usr/local/{bin,lib,include}。这极大地简化了ld.so.confor LD_LIBRARY_PATH/LD_RUN_PATH尽管您将需要忍受混乱/usr/local/{bin,lib,include}。
/usr/lib/执行此操作的“官方”方法是使用系统的包管理器并在所选位置( 、/lib等)安装发行版的库的维护版本。
| 归档时间: |
|
| 查看次数: |
26926 次 |
| 最近记录: |