[SciPy-User] Linking to BLAS from an extension

Hjalmar Turesson hturesson@gmail....
Tue Oct 25 20:51:25 CDT 2011


I'm trying to call dgemm (a BLAS routine) from a C extension. It compiles
fine, but when I try to import my python file containing the extension, I
get an import error:

ImportError: ./_C_fast_spikesort.so: undefined symbol: dgemm_

>From http://www.math.utah.edu/software/lapack.html I got the impression that
gcc doesn't automatically record the location of the BLAS libary, so that at
runtime dgemm is not found. Thus, they recommend to put the LDFLAGS line in
the make file. But this doesn't help. Make file below:

# ---- Record the location of BLAS-----
LDFLAGS  = Wl, -rpath /usr/lib

# ---- Link ---------------------------
_C_fast_spikesort.so:  C_fast_spikesort.o
gcc -shared C_fast_spikesort.o -o _C_fast_spikesort.so

# ---- gcc C compile ------------------
C_fast_spikesort.o:  C_fast_spikesort.c C_fast_spikesort.h
gcc -c -fPIC C_fast_spikesort.c -I/usr/include/python2.7
-I/usr/lib/python2.7/site-packages/numpy/core/include/numpy -L /usr/lib

How should I fix it? Is it better to use cblas, and include cblas.h instead?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20111025/5dfcbde6/attachment.html 

More information about the SciPy-User mailing list