python extensions: including project local headers

Robert Kern robert.kern at gmail.com
Thu Oct 23 12:43:06 EDT 2008


J Kenneth King wrote:
> Robert Kern <robert.kern at gmail.com> writes:
> 
>> 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
>>>
>>> Kenneth,
>>> 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.
> 
> I'm including Rob Hess' sources with the extension.
> 
> Would that mean I should add library_dirs to Extension() to point to the
> sources in the project's path?

No, you would add the source file names to the sources= list.

-- 
Robert Kern

"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 mailing list