How to import C++ static library?

Paul Anton Letnes paul.anton.letnes at gmail.com
Tue Apr 15 11:40:27 CEST 2008


Den 15. april. 2008 kl. 11.11 skrev Diez B. Roggisch:

> Alexander Dong Back Kim wrote:
>
>> Hi all,
>>
>> I'm very very beginner of python but I'm dare to ask this question
>> straight away. =P
>>
>> Is it possible to import C++ static library compiled by GCC? The
>> target is definitely Linux machine.
>>
>> I found some examples from Google showing the way C++ can import
>> Python so called embedded python. But I want to the opposite way of
>> this. I want to import (or include in C world terminology) the  
>> library
>> which is a blah.a file to reuse in python.
>>
>> Any suggestion or idea for this stupid beginner? ;)
>
> For C++, you need to create a wrapping using C++ wrapper tools.  
> There are a
> few available: SWIG, Boost::Python and SIP.
>
> I can only comment personally on the latter - and can recommend it  
> without
> any doubt.
>
> Diez
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Diez: I tried SWIG, and it works nicely with C. For C++, I didn't  
manage to make it work. I tried SIP; I have some problems compiling  
etc. Would it be too much to ask you to supply a working example of a  
(simple, stupid) C++ class and the necessary SIP files? Preferably for  
Mac OS X, but Linux is also interesting I guess.


Cheers
Paul.



More information about the Python-list mailing list