简体   繁体   English

Linux:在运行时更改LD_LIBRARY_PATH

[英]Linux: alter LD_LIBRARY_PATH at runtime

I'm working on a simple plugin architecture for my app. 我正在为我的应用程序设计一个简单的插件体系结构。 A plugin is a shared object with a known "get interface" function. 插件是具有已知“获取接口”功能的共享对象。 I access the .so via dlopen/dlsym etc. Fairly standard. 我通过dlopen / dlsym等访问.so。相当标准。 Some of my plugins have extra .so files that need to be loaded too. 我的某些插件还有额外的.so文件,也需要加载。 These files can be shipped with a plugin fine, but I need the app to know where/how to load them. 这些文件可以附带一个很好的插件,但是我需要应用程序知道在哪里/如何加载它们。

So my question is: how to I add a particular plugin's directory to the list of places to look for libraries? 所以我的问题是:如何将特定插件的目录添加到要查找库的位置列表中? I can't set LD_LIBRARY_PATH before starting the app, as the plugin will be loaded some time later. 在启动应用程序之前,我无法设置LD_LIBRARY_PATH,因为该插件将在一段时间后加载。 Alternatively, do I need each plugin to explicitly provide the list of dependencies in some kind of manifest file, so that I may load them with dlopen() first? 或者,是否需要每个插件在某种清单文件中显式提供依赖项列表,以便可以首先使用dlopen()加载它们? Thanks. 谢谢。

Edit: to clarify, the plugins' directories are not known prior to starting the app, so I cannot set the LD_LIBRARY_PATH at that time. 编辑:澄清一下,在启动应用程序之前不知道插件的目录,因此我当时无法设置LD_LIBRARY_PATH。

根据这个 Linux的评估LD_LIBRARY_PATH开始应用之前,所以不知道你做在运行时的任何变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM