View Full Version : writing python modules to use gsl with Mac OS X 10.5

Jan 24, 2009, 08:45 AM
I'm a total Mac newbie trying to migrate my programs from Windows and Linux - I have a python module which wraps a couple of gsl routines (gsl_sf_coupling_3j and gsl_sf_coupling_6j) and installs with distutils on Windows and Ubuntu Linux, but when I try to import it on my Mac, it complains:
Symbol not found: _cblas_caxpy
Referenced from: /usr/local/lib/libgsl.0.dylib
Expected in: dynamic lookup

I don't really understand what's going on. I can call the gsl routines from a C++ program importing the gsl libraries directly, so they're clearly working.
Any idea what might be wrong? I haven't found a lot of help on t'Internet.

Jan 24, 2009, 10:36 AM
OK - scratch that. It works now: I wasn't linking in the BLAS libraries. All is good.

May 25, 2011, 01:57 PM
Hi xnn, I am trying to load the gsl shared library from Python 2.6 using ctypes on Mac OS X 10.6 but I have the problem as you :

from ctypes import cdll

The symbol _cblas_caxpy is not found

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libgsl.dylib, 6): Symbol not found: _cblas_caxpy
Referenced from: /usr/local/lib/libgsl.dylib
Expected in: flat namespace
in /usr/local/lib/libgsl.dylib

I have also tried

from ctypes import cdll

Without success.
Could elaborate on how you solved your problem ?

May 25, 2011, 02:09 PM
Talk about Murphy's Law. After about one hour looking for an answer, I decided to post here. 5 minutes later I found an answer.

The following code resolves the issue by making the cblas symbols global :

from ctypes import CDLL
gslcblas = CDLL('libgslcblas.dylib',mode=RTLD_GLOBAL)
gsl = CDLL('libgsl.dylib')