newbie-question: extending python with c++

merman merman at freenet.de
Mon Apr 15 08:44:29 EDT 2002


Hi there,

I have a c++ -class; I can compile this class successful as standalone-app.
No problem.
Now I want to work with swig.

There are three files: Tree.cpp, Tree.h, Tree.i

first step:
swig -python -c++ -o Tree_wrap.cpp Tree.i (output is Tree_wrap.cpp - it's
ok)

second step:
g++ -c Tree.cpp Tree_wrap.cpp -IC:\python22\include (also ok - output are
Tree.o and Tree_wrap.o)

third step - *build*:
g++ Tree.o Tree_wrap.o -shared -o Tree.dll (this line throws lots of
failures - whats wrong?)

failure-examples:

Tree_wrap.o(.text+0x311):Tree_wrap.cpp: undefined reference to
`_imp__PyString_FromString'
Tree_wrap.o(.text+0x441):Tree_wrap.cpp: undefined reference to
`_imp__PyExc_NameError'
Tree_wrap.o(.text+0x44a):Tree_wrap.cpp: undefined reference to
`_imp__PyErr_SetString'
Tree_wrap.o(.text+0x4c1):Tree_wrap.cpp: undefined reference to
`_imp__PyExc_NameError'
Tree_wrap.o(.text+0x4ca):Tree_wrap.cpp: undefined reference to
`_imp__PyErr_SetString'

... and so on. Is there a llinker-problem?

I work on win2k with MINGW (gcc for win32). My python-ver. is python2.2.1c1.

Can anybody help?

regards thomas







More information about the Python-list mailing list