9

我在这里玩弄的包是相当未知的,但问题是相当普遍的。基本上,我正在尝试用 C++ 扩展编译 Python 模块(称为 rql)。该扩展使用名为 gecode 的外部框架,其中包含多个库。我编译了gecode并在本地安装。现在,让输出说明一切:

red@devel:~/build/rql-0.23.3$ echo $LD_LIBRARY_PATH
/home/red/usr/lib
red@devel:~/build/rql-0.23.3$ ls $LD_LIBRARY_PATH | grep libgecodeint 
libgecodeint.so
libgecodeint.so.22
libgecodeint.so.22.0
red@devel:~/build/rql-0.23.3$ python setup.py build
running build
running build.py
package init file './test/__init__.py' not found (or not a regular file)
running build_ext
building 'rql_solve' extension
g++ -pthread -shared build/temp.linux-i686-2.5/gecode-solver.o -lgecodeint -lgecodekernel -lgecodesearch -o build/lib.linux-i686-2.5/rql_solve.so
/usr/bin/ld: cannot find -lgecodeint
collect2: ld returned 1 exit status
error: command 'g++' failed with exit status 1
4

2 回答 2

14

LD_LIBRARY_PATH用于运行时链接器/加载器(使用 可以达到相同的效果ldconfig)。你需要的是-L旗帜:

-L/home/red/usr/lib

在编译器命令行上。

编辑:

而且 - 感谢@bjg 提醒我 -LIBRARY_PATH如果您不想弄乱编译器选项,可以使用。

于 2010-07-10T23:20:58.780 回答
1

您显然已修改LD_LIBRARY_PATH为指向主目录中的非标准位置。您知道LD_LIBRARY_PATH在 setup.py 中用于调用 g++ 的环境是否与您的 shell 环境匹配?

看看你是否可以传递参数来setup.py修改库路径或简单地传递-L/home/red/usr/lib给 g++。

于 2010-07-10T23:20:26.207 回答