GNU ld无法找到存在的库 [英] GNU ld cannot find library which is there

查看:105
本文介绍了GNU ld无法找到存在的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里使用的软件包是一个未知数,但是尽管如此,这个问题还是很普遍的.基本上,我正在尝试编译具有C ++扩展名的Python模块(称为rql).该扩展使用名为gecode的外部框架,该框架包含多个库.我编译了gecode并在本地安装.现在,让输出说明一切:

The packages I'm toying with here are rather unknown, but nevertheless the problem is rather generic. Basically, I'm trying to compile Python module (called rql) with C++ extension. The extension uses external framework called gecode, which contains several libraries. I compiled gecode and installed locally. Now, let the output speak for itself:

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

推荐答案

LD_LIBRARY_PATH用于运行时链接程序/加载程序(使用

LD_LIBRARY_PATH is for runtime linker/loader (same effect could be achieved with ldconfig ). What you need is the -L flag:

-L/home/red/usr/lib

在编译器命令行上.

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

And - thanks to @bjg for reminding me - you can use LIBRARY_PATH if you don't want to mess with compiler options.

这篇关于GNU ld无法找到存在的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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