Cython-gsl scientific library error

0 sulabh tiwari · November 3, 2014
Hi guys,

I am using cython and i wanted to import gnu scientific C library . I first installed this library in  /home/sulabh folder
After that i followed following procedure
1. Created a file gsl_test.pyx
cdef extern from "gsl/gsl_math.h":
    double gsl_pow_int (double x, int n)

def gibbs(double k, int t):
    y = gsl_pow_int (k, t)
    return y

2. created a setup.py file
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy

include_gsl_dir = "/home/sulabh/include/"
lib_gsl_dir = "/home/sulabh/lib/"

 
ext = Extension("sl", sources = ["gsl_test.pyx"],include_dirs=[numpy.get_include(),include_gsl_dir],library_dirs=[lib_gsl_dir],libraries=["gsl"])
 
setup(ext_modules=[ext],
    cmdclass = {'build_ext': build_ext})

3. run python setup.py build_ext --inplace

which resulted into sl.o

i have entered into python console to import this module by writing import sl

but i got an error
>>> import sl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home/sulabh/lib/libgsl.so.0: undefined symbol: cblas_dasum


here is how my package configuration looks like

prefix=/home/sulabh/gsl-1.16/..
exec_prefix=/home/sulabh/gsl-1.16/..
libdir=/home/sulabh/gsl-1.16/../lib
includedir=/home/sulabh/gsl-1.16/../include
GSL_CBLAS_LIB=-lgslcblas


Name: GSL
Description: GNU Scientific Library
Version: 1.16
Libs: -L/home/sulabh/gsl-1.16/../lib -lgsl ${GSL_CBLAS_LIB} -lm -lm
Cflags: -I/home/sulabh/gsl-1.16/../include

can anybody would like to help... what can be a problem...
thanks in advance







Post a Reply

Replies

Oldest  Newest  Rating
0 Doug Fresh · November 11, 2014
if anyone is curious, here's the solution:


Add "gslcblas" to the list of libraries in the function call 
Extension

, i.e.
ext = Extension(...,libraries=["gsl", "gslcblas"])

Or other BLAS library you'd like to add.


answered Nov 3 at 5:08
William Zhang



pulled from http://stackoverflow.com/questions/26705303/using-cython-in-combination-with-gsl
  • 1

Python

106,952 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator