python extensions: including project local headers
robert.kern at gmail.com
Thu Oct 23 17:55:24 CEST 2008
Philip Semanchuk wrote:
> On Oct 23, 2008, at 11:36 AM, J Kenneth King wrote:
>> Hey everyone,
>> I'm working on a python extension wrapper around Rob Hess'
>> implementation of a SIFT feature detector. I'm working on a
>> computer-vision based project that requires interfacing with Python at
>> the higher layers, so I figured the best way to handle this would be in
>> C (since my initial implementation in python was ungodly and slow).
>> I can get distutils to compile the extension and install it in the
>> python path, but when I go to import it I get the wonderful exception:
>> ImportError: /usr/lib/python2.5/site-packages/pysift.so: undefined
>> symbol: _sift_features
> You're close but not interpreting the error quite correctly. This isn't
> an error from the compiler or preprocessor, it's a library error.
> Assuming this is dynamically linked, your OS is reporting that, at
> runtime, it can't find the library that contains _sift_features. Make
> sure that it's somewhere where your OS can find it.
It looks like the library implementing it was not linked into the extension.
sift_features() is not part of OpenCV.
James, are you including the source of Rob Hess's implementation with your
extension, or are you trying to link against an already installed version of the
library? If the former, you need to add the C sources to the pysift Extension().
If the latter, you need to add the name of the library to the list of libraries.
Also, you don't want to pass the list of libraries with extra_link_args.
Instead, use libraries=.
pysift = Extension('pysift',
include_dirs = ['sift/include'],
sources = ['src/pysift.c'],
libraries = ['feat', 'cv', 'cxcore', 'highgui',
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list