Boost Python(Suse 和 Ubuntu)
我创建了一个简单的 .so 库,其中包含 C++ 类的定义,该类应该从 Python 访问并用于此目的 boost python 库。 当我使用 x64 Ubuntu 测试这个库时,在运行 python 之前将 LD_LIBRARY_PATH 设置为 boost 库的路径就足够了。但是,当我使用 x64 Suse 时,它不起作用。 尽管我设置了 LD_LIBRARY_PATH,但 Python 似乎忽略了它。
Suse下有没有具体的设置环境变量的方法?
I created a simple .so library containing definition of a C++ class which should be accessed from Python and used for this purpose boost python library.
When I'm testing this library using x64 Ubuntu it is enough to set LD_LIBRARY_PATH with the path to boost libs before running python. It doesn't work, however, when I'm using x64 Suse.
Altough I'm setting LD_LIBRARY_PATH it seems that Python ignores it.
Is there any specific way to set environmental variables under Suse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您永远不应该设置
LD_LIBRARY_PATH
,请参阅此处和此处。首先,我必须假设您将 Boost 库安装在非标准位置,否则加载程序会自动找到它们。如果您具有计算机的 root 访问权限,请将库安装在标准位置(例如使用包管理器,或在
/usr/local/lib
中)。如果您没有 root 权限,请设置运行路径。使用 gcc 链接器时,通过传递
-rpath
选项来执行此操作。 gcc 编译器可以通过-Wl
将选项传递给链接器。因此调用编译器如下:You should never set
LD_LIBRARY_PATH
, see here and here.First of all I have to assume that you installed the Boost libraries in a nonstandard location, otherwise the loader would find them automatically. If you have root access to the machine, install the libraries in a standard place (e.g. with the package manager, or in
/usr/local/lib
).If you don't have root privileges, set the runpath instead. When using the gcc linker, do this by passing an
-rpath
option. The gcc compiler can pass options to the linker via-Wl
. So call the compiler as follows: