GNU ld cannot find library which is there
Asked Answered
G

2

9

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
Gainsborough answered 10/7, 2010 at 23:12 Comment(2)
Is LD_LIBRARY_PATH exported in your environment?Subvert
Is the libgecodeint.so that is in your LD_LIBRARY_PATH for the right architecture (e.g. 32-bit or 64-bit as appropriate)?Slumlord
S
14

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

on the compiler command line.

Edit:

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

Sabrina answered 10/7, 2010 at 23:20 Comment(1)
Yes, I would mark his comment as answer if I could :) It's kinda strange that ld doesn't look in it's runtime search path anyway, but the problem is solved now, so big thanks to you and others here!Gainsborough
D
1

You've apparently modified LD_LIBRARY_PATH to point to a non-standard location in your home directory. Do you know if LD_LIBRARY_PATH in the environment used to call g++ in setup.py matches your shell's environment?

See if you can pass arguments to setup.py to modify the library path or simply pass -L/home/red/usr/lib to g++.

Devout answered 10/7, 2010 at 23:20 Comment(1)
g++ will use LIBRARY_PATH if present so you could try LIBRARY_PATH=/red/usr/lib python setup.py buildSubvert

© 2022 - 2024 — McMap. All rights reserved.