writing python modules to use gsl with Mac OS X 10.5

Discussion in 'Mac Programming' started by xnn, Jan 24, 2009.

  1. xnn
    macrumors newbie

    Joined:
    Jan 24, 2009
    #1
    Hello,
    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.
    Thanks,
    xnn
     
  2. xnn
    thread starter macrumors newbie

    Joined:
    Jan 24, 2009
    #2
    OK - scratch that. It works now: I wasn't linking in the BLAS libraries. All is good.
     
  3. macrumors newbie

    Joined:
    May 25, 2011
    #3
    Same problem loading libgsl.dylib

    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 :

    Code:
    from ctypes import cdll
    cdll.LoadLibrary("libgsl.dylib")
    The symbol _cblas_caxpy is not found

    Code:
    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

    Code:
    from ctypes import cdll
    cdll.LoadLibrary("libcblas.dylib")
    cdll.LoadLibrary("libgslcblas.dylib")
    cdll.LoadLibrary("libgsl.dylib")
    Without success.
    Could elaborate on how you solved your problem ?
     
  4. macrumors newbie

    Joined:
    May 25, 2011
    #4
    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 :

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

Share This Page