Python and c++ problem

Hi!

I’m trying to make a pice of code with c++. I’m runnting under Linux (Ubuntu 64bits). I can compile the c++ source, but then I don’t know how to import under python.
After compile I have the object file (.o). I need a lib like (.a) or (.so)?
There are some examples or tutorials on the net? I can’t find it.

Any help will be wellcome.

Thanks.

You have to compile it to .so, and you have to provide some wrapper functions in a format that Python expects. You can either write these functions by hand, or you can use a tool such as SWIG or Panda’s interrogate to write them for you.

If this is your first experience integrating C++ code and Python code, you might do well to investigate SWIG.

David

You could also write C bindings for your game and use your library with ctypes. This is maybe one of the easiest solutions.

Thanks!

I try interrogate but after a few hours I still with problems. Now I will look for SWIG information.