在 Solaris 上哪里设置 LD_LIBRARY_PATH?
在 Solaris 上设置应用程序特定 LD_LIBRARY_PATH
变量的最佳位置是什么? 如何
LD_LIBRARY_PATH
变量有效吗?
目前我们在.kshrc
中进行设置,但是不同的应用程序需要不同版本的消息传递框架,但这些应用程序在相同的用途下运行,因此它们需要不同的LD_LIBRARY_PATH
,所以您认为设置此变量的最佳位置是什么?
基本上我想弄清楚如何使这个变量路径成为应用程序的一部分,而不是特定于用户环境。
What is the best place to set up application specific LD_LIBRARY_PATH
variable on Solaris?
How does
LD_LIBRARY_PATH
variable work?
We currently set it up in .kshrc
, but different applications need different versions of messaging framework, but these applications run under the same use and hence they would need different LD_LIBRARY_PATH
, so in your opinion what is the best place to set this variable?
Basically I am trying to figure out how to make this variable path part of the application instead of user environment specific.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
通常我只会有一个启动应用程序的 shell 脚本。 在 shell 脚本中,我将 LD_LIBRARY_PATH 设置为该应用程序所需的任何内容,然后让脚本启动该应用程序。 这样做应该会导致仅为该应用程序设置路径。
Usually I would just have a shell script that starts the application. In the shell script I would set LD_LIBRARY_PATH to whatever I need it to be for that app, then have the script start that app. Doing it that way should cause the path to be set only for that application.
您可以在“ld.so.1”的手册页上找到
LD_LIBRARY_PATH
的正式描述,即运行“man ld.so.1”。 它还描述了运行时链接器所遵循的一些其他变量。除了
LD_LIBRARY_PATH
之外,可执行文件和共享库还可以具有内置的库搜索路径。 如果您正在运行自己链接的应用程序,则可以使用 ld 的 -R 选项来设置内置路径(Sun CC 和 gcc 都具有执行相同操作的选项)。 这可能会让您从一开始就避免使用LD_LIBRARY_PATH
。You can find a formal description of
LD_LIBRARY_PATH
on the man page for "ld.so.1", ie run "man ld.so.1". It also describes some other variables that are honored by the runtime linker.In addition to
LD_LIBRARY_PATH
, executables and shared libraries can also have a built-in search path for libraries. If you are running an application that you have linked yourself, you can use ld's -R option to set the built in path (both Sun CC and gcc have options to do the same thing). This may allow you to avoid usingLD_LIBRARY_PATH
in the first place.弗拉德,阿兰克是正确的。
不建议在 Solaris 上设置 LD_LIBRARY_PATH。 完全没有。
如果您需要将特定的运行路径烘焙到库或可执行文件中,
那么你应该对链接器使用 -R 标志。 如果使用 gcc 构建,那么
使用 -Wl,Rpath (我认为)。
如果您需要在构建后步骤中执行此操作(例如,因为您缺少
源重新编译),然后 elfedit(1) 会对你有很大帮助。 已记录在案
在联机帮助页中,以及位于 http:// docs.oracle.com/cd/E26502_01/html/E26507/index.html
Vladr, alanc is correct.
It's not recommended to set LD_LIBRARY_PATH on Solaris. At all.
If you need to bake a specific runpath into your library or executable,
then you should use the -R flag to the linker. If building with gcc, then
use -Wl,Rpath (I think).
If you need to do this for a post-build step (eg, because you're lacking
source to recompile), then elfedit(1) will help you a lot. It's documented
in the manpage, and also in the Linker+Libraries Guide at http://docs.oracle.com/cd/E26502_01/html/E26507/index.html
crle 的回答是最正确的。 在 Solaris 上,不应使用
LD_LIBRARY_PATH
。 请改用 crle。 要查看当前路径,只需单独运行“crle”即可。 要更新列表,请使用 crle -u -l /path/to/your/lib/directory。 需要使用-u
来写入对系统配置的更改,否则更改将是暂时的。 有关更多选项,请参阅手册页。The crle response is most correct. On Solaris,
LD_LIBRARY_PATH
shouldn't be used. Use crle instead. To view the current paths, just run "crle" by itself. To update the list, usecrle -u -l /path/to/your/lib/directory
. The-u
is needed to write changes to the system configuration, otherwise the change will be temporary. See the man page for more options.刚刚发现全局LD_LIBRARY_PATH不生效的情况,我不得不包装一个脚本并在应用程序之前设置LD_LIBRARY_PATH。
如果您通过blastwave 中的pkgutil 在/opt/csw/lib 下安装了很多库,那么crle 是一个很好的全局解决方案。
Just found a case that global LD_LIBRARY_PATH doesn't take effect, I had to wrap a script and set LD_LIBRARY_PATH before the app.
crle is a good global solution if you installed a lot of libs under /opt/csw/lib, via pkgutil from blastwave.
您可以检查您的 .profile 或 .profile.user 文件。将会有一个带注释的条目。不建议使用它,因为它已损坏。您应该通过将值传递给标志而不是使用变量来构建二进制文件。
You can check your .profile or .profile.user file.There will be be a commented entry for it .It's not recommended to be used since it's broken.You should build the binaries by passing values to flags rather than using the variable.
您可以使用 crle 命令:
crle -l /path/to/your/lib/file
You can use the crle command:
crle -l /path/to/your/lib/file