Question

I'm trying to install the python package cvxopt via pip into a virtual environment on a Centos 6 system.

Since lapack is a prerequisite, and since I don't have superuser access to the system, I've installed lapack locally using the following:

$ cmake -DCMAKE_INSTALL_PREFIX=/home/tom .
$ make install

I notice that after this step liblapack.a is located in my local lib directory, /home/tom/lib, as expected.

However, when I activate my virtual environment and run pip install cvxopt I get the following error:

<snip>
gcc -pthread -shared
build/temp.linux-x86_64-2.7/src/C/base.o 
build/temp.linux-x86_64-2.7/src/C/dense.o
build/temp.linux-x86_64-2.7/src/C/sparse.o
-L/usr/lib -L/public/apps/python/2.7.4/lib
-lm -llapack -lblas -lpython2.7 -o build/lib.linux-x86_64-2.7/cvxopt/base.so

/usr/bin/ld: cannot find -llapack

collect2: ld returned 1 exit status

error: command 'gcc' failed with exit status 1

I've tried adding /home/tom/lib to both LD_LIBRARY_PATH and LD_RUN_PATH but neither of these seem to affect the gcc command line options that pip is using to build the module.

Can anyone tell me how to give library search paths to pip? Is there a better way?

Was it helpful?

Solution

After some experimentation, I was able to solve the problem. The first thing I had to do was enable the shared libraries for LAPACK:

~/src/lapack-3.5.0 $ cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/home/tom .
~/src/lapack-3.5.0 $ make install

Then I exported LD_FLAGS to include the proper library search path:

export LD_FLAGS="-L/home/tom/lib"

Then I re-attempted the install of cvxopt from source into the virtual environment:

~/src/cvxopt-1.1.6 $ . venv/bin/activate
~/src/cvxopt-1.1.6 (venv)$ python setup.py build install

I didn't experiment with LD_LIBRARY_PATH or LD_RUN_PATH to determine whether they were still required with LD_FLAGS. However, I did determine that a shared LAPACK library was definitely required; cvxopt wouldn't link against the static library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top