Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Cython wrapper cannot find the symbols defined by BLAS #10

Closed
argoncloud opened this issue Nov 14, 2011 · 3 comments
Closed

The Cython wrapper cannot find the symbols defined by BLAS #10

argoncloud opened this issue Nov 14, 2011 · 3 comments

Comments

@argoncloud
Copy link
Collaborator

I am having an issue with cython. The cython file compiles correctly to C, and the C file also compiles correctly to .so (see first target of the Makefile on branch caa_devel). However, when I import the .so in python, python complains that
ImportError: ./pasgd.so: undefined symbol: cblas_sdsdot

I am not using cblas_sdsdot in python, and also the function is in fact defined (either in simple_blas.c or from libcblas.so). This sounds like a silly issue, like me not giving some necessary parameter to Python. Did you ever encounter something like this? Suggestions?

@npinto
Copy link
Owner

npinto commented Nov 14, 2011

How did you link the shared library ?

Here is an example of setup.py (the one you call with python setup.py build_ext --inplace):


from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

import numpy

ext_modules=[
    Extension("fbcorr_cython", ["fbcorr_cython.pyx"],
              include_dirs = [numpy.get_include(),'.'],
              libraries=['cblas'],
              extra_compile_args = \
              ["-O3", "-Wall",
               "-pthread",
               "-fopenmp",
               #"-ffast-math",
               #"-funroll-all-loops",
               "-msse2",
               "-msse3",
               "-msse4",
               #"-fomit-frame-pointer",
               "-march=native",
               "-mtune=native",
               "-ftree-vectorize",
               "-ftree-vectorizer-verbose=2",
               #"-fwrapv",
              ],
              ),
]

setup(
  cmdclass = {'build_ext': build_ext},
  ext_modules = ext_modules,
)

The relevant line is in the libraries kwarg.

@argoncloud
Copy link
Collaborator Author

Nevermind, the problem is that I accidentally misnamed the shared
library as .o instead of .so - changing that solved it.

I am not using setup.py, I am compiling the files manually via Makefile
with the same calls specified at http://wiki.cython.org/tutorials/numpy
it's more convenient because with the Makefile variables you can use the
same parameters for compiling everything.

On 11/13/2011 10:56 PM, Nicolas Pinto wrote:

How did you link the shared library ?

Here is an example of setup.py (the one you call with python setup.py build_ext --inplace):


from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

import numpy

ext_modules=[
    Extension("fbcorr_cython", ["fbcorr_cython.pyx"],
              include_dirs = [numpy.get_include(),'.'],
              libraries=['cblas'],
              extra_compile_args = \
              ["-O3", "-Wall",
               "-pthread",
               "-fopenmp",
               #"-ffast-math",
               #"-funroll-all-loops",
               "-msse2",
               "-msse3",
               "-msse4",
               #"-fomit-frame-pointer",
               "-march=native",
               "-mtune=native",
               "-ftree-vectorize",
               "-ftree-vectorizer-verbose=2",
               #"-fwrapv",
              ],
              ),
]

setup(
  cmdclass = {'build_ext': build_ext},
  ext_modules = ext_modules,
)

The relevant line is in the libraries kwarg.


Reply to this email directly or view it on GitHub:
#10 (comment)

@npinto
Copy link
Owner

npinto commented Nov 16, 2011

For Cython modules, please use setup.py or we'll have many issues in the future.

@npinto npinto closed this as completed Mar 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants