在Mac OS X上使用DYLD_LIBRARY_PATH可以吗?而且,动态库搜索算法是什么? [英] Is it OK to use DYLD_LIBRARY_PATH on Mac OS X? And, what's the dynamic library search algorithm with it?

查看:778
本文介绍了在Mac OS X上使用DYLD_LIBRARY_PATH可以吗?而且,动态库搜索算法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一些不鼓励使用DYLD_LIBRARY_PATH的文章,因为应该使用-install_name,@rpath和@loader_path来修复动态库的路径。

I read some articles discouraging of the use of DYLD_LIBRARY_PATH, as the the path of dynamic library should be fixed using -install_name, @rpath, and @loader_path.

在制作在Linux和Mac OS X上运行的程序方面,Mac OS X的DYLD_LIBRARY_PATH完全符合Linux的LD_LIBRARY_PATH。而且,我们可以共享(几乎)没有-install_name和@rpath的同一个make文件。

In terms of making a program that runs both on Linux and Mac OS X, DYLD_LIBRARY_PATH of Mac OS X does exactly what LD_LIBRARY_PATH of Linux. And, we can share (almost) the same make file that doesn't have the -install_name and @rpath.


  • 是否可以在Mac OS X上使用DYLD_LIBRARY_PATH?

  • 什么是动态库搜索算法用Mac OS X时,二进制文件找不到动态库?当前目录 - > DYLD_LIBRARY_PATH目录...?

推荐答案

正如您所说, DYLD_LIBRARY_PATH 在其他* nix上的行为类似于 LD_LIBRARY_PATH 。但是,另外还有一个环境变量,你应该看一下调用 DYLD_FALLBACK_LIBRARY_PATH

As you've noted, DYLD_LIBRARY_PATH behaves like LD_LIBRARY_PATH on other *nix. However, there is another environment variable you should look at called DYLD_FALLBACK_LIBRARY_PATH.

osx和linux)建议仅用于开发使用,因为当您使用不具有相同符号表的库替换时,它们可能会导致符号查找错误。一个很好的例子是当您尝试使用自定义安装来覆盖VecLib(例如blas lapack)的默认安装。如果 DYLD_LIBRARY_PATH 被设置,并且反之亦然(如果不是自定义应用程序中的符号查找错误),这将导致链接到系统VecLib的应用程序中找不到符号未找到错误。这是由于系统blas / lapack不是ATLAS库的完全实现。

In general, these are (both on osx and linux) suggested only for development use as they can cause symbol lookup errors when you override with a library that does not have the same symbol table. A good example of this is when you attempt to override the default install of VecLib (e.g. blas lapack) with a custom install. This will cause symbol not found errors in applications linked to the system VecLib if DYLD_LIBRARY_PATH is set and the reverse (symbol lookup errors in custom applications) if it is not. This is due to the system blas/lapack not being a full implementation of the ATLAS libs.

DYLD_FALLBACK_LIBRARY_PATH 不会产生这些问题。

将库安装到非标准位置时, DYLD_FALLBACK_LIBRARY_PATH 更加理智。这将在默认路径中提供的库中查找符号,如果在那里找不到该符号,则返回到指定的路径。

When installing libraries to a non-standard location, DYLD_FALLBACK_LIBRARY_PATH is much more sane. This will look for symbols in libraries provided in the default paths and if the symbol is not found there, fall back to the specified path.

好处是这个过程不会在针对默认库编译的应用程序中导致符号查找错误。

The benefit is that this process will not cause symbol lookup errors in applications compiled against the default libraries.

通常,当库被安装到非标准位置时,应该指定绝对路径,否定动态查找的模糊性。

In general, when libraries are installed to non-standard locations absolute paths should be specified which negates the ambiguity of the dynamic lookup.

这篇关于在Mac OS X上使用DYLD_LIBRARY_PATH可以吗?而且,动态库搜索算法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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