How to import C++ static library?

  • Thread starter Alexander Dong Back Kim
  • Start date
A

Alexander Dong Back Kim

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? ;)

cheers,
Alex
 
D

Diez B. Roggisch

Alexander said:
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
 
P

Paul Anton Letnes

Den 15. april. 2008 kl. 11.11 skrev Diez B. Roggisch:
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

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.
 
D

Diez B. Roggisch

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.

I do have some code at home, if I remember this I'll try & post it.

However, I suggest you get PyQt and inspect it. And actually I found the
SIP-documentation _very_ helpful!

Diez
 
D

Diez B. Roggisch

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.

http://roggisch.de/IrrSinn.tgz

That's a pet-project of mine. You won't make it compile though! Just see
if it works for you as a template.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top