[C++-SIG] Python calling C++ issues

Ephi Dror ephi at adital.com
Tue Nov 23 07:49:57 CET 1999


Hi All,

We are exploring the possibility of using Python with conjunction with C++.

I recently posted the "Beginner Question" and would like to thank all of you
for the great discussion and support we have received.

We have managed to make  great progress however we run into couple of  very
strange problems which I would like to bring up here and share them with the group.
Any help in solving these issues will be highly appreciated and beneficiary for all. 
We also think that the attached example could be good starting point for beginners to understand the concept of calling C++ objects from Python.

The example contains a simple C++ class with two data members and we have a simple python script which uses the class.
 
The two problems are:
1. The value of the first data member in the class is ok in the constructor,
but in all the rest of the member functions it added 2 to the first data
member.
2. When we call the destructor, It is executing the destructor, but   we get
"Segmentation fault" after it finished to execute the python script that
calls the functions that call c++ functions.

Here is general information on:
1. We use Linux version 6.1 from redhat.
2. We use gcc version egcs-2.91.66 from redhat.
3. we use Python version 1.5.2 compiled with same gcc from redhat.
4. The class files are: spam.cpp and spam.h .
5. The files that include the c functions that wrap the class functions are :  c_spam.cpp and c_spam.h .
6. The file that has the module extension is : ext_spam.cpp.
7. The file that includes the Python script that call the c++ is run.
 
We suspect that the problems might be one or combination of the following issues:
2. Makefile bug (C++ flags and/or shared lib flags are missing).
3. Incompatibility between the way python was built and the version of GCC/C++ we use for the example.
 
Thanks a lot in advance for your cooperation ,
 
Cheers,
Ephi.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/19991122/0c0ace37/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spam.tgz
Type: application/x-compressed
Size: 1299 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/19991122/0c0ace37/attachment.bin>


More information about the Cplusplus-sig mailing list