Compiling Python C++ extensions with MingW
I posted details of a problems on the google Python user group - someone emailed to say that I should send this to the distutils-sig. mailing list. It concerns compiling a very simple C++ extension (as a test) on Mingw 2.0.0 for use with MSVC-compiled Python. Using linker option --enable-cxx did not help. http://groups.google.co.uk/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=2830c89 c.0212101559.6ea63560%40posting.google.com&prev=/groups%3Fhl%3Den%26lr%3 D%26ie%3DUTF-8%26group%3Dcomp.lang.python The output is shown below. The SWIG warnings seem to be normal - but it failed at the dllwrap stage. Andrew Gregory. C:\PyFiles\exMingw\MyCPP>python setup.py build --compiler=mingw32 running build running build_ext building '_pysimple' extension creating build creating build\temp.win32-2.2 creating build\temp.win32-2.2\Release C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python22\include -c pysimple_wrap.cxx -o build\temp.win32-2.2\Relea se\pysimple_wrap.o pysimple_wrap.cxx:180: warning: `swig_type_info* SWIG_TypeDynamicCast(swig_type_info*, void**)' defined but not used pysimple_wrap.cxx:192: warning: `swig_type_info* SWIG_TypeQuery(const char*)' defined but not used pysimple_wrap.cxx:374: warning: `void SWIG_addvarlink(PyObject*, char*, PyObject*(*)(), int (*)(PyObject*))' defined but not used pysimple_wrap.cxx:427: warning: `int SWIG_ConvertPtr(PyObject*, void**, swig_type_info*, int)' defined but not used pysimple_wrap.cxx:519: warning: `int SWIG_ConvertPacked(PyObject*, void*, int, swig_type_info*, int)' defined but not used writing build\temp.win32-2.2\Release\_pysimple.def creating build\lib.win32-2.2 C:\MinGW\bin\dllwrap.exe -mno-cygwin -mdll -static --entry _DllMain@12 --output-lib build\temp.win32-2.2\Release\lib_pys imple.a --def build\temp.win32-2.2\Release\_pysimple.def -s build\temp.win32-2.2\Release\pysimple_wrap.o -LC:\Python22\l ibs -lpython22 -o build\lib.win32-2.2\_pysimple.pyd build\temp.win32-2.2\Release\pysimple_wrap.o(.eh_frame+0x11):pysimple_wr ap.cxx: undefined reference to `__gxx_personalit y_v0' dllwrap: gcc exited with status 1 error: command 'dllwrap' failed with exit status 1 ------------------------------------------------------------------- This e-mail and any attachments may contain confidential and/or privileged material; it is for the intended addressee(s) only. If you are not a named addressee, you must not use, retain or disclose such information. NPL Management Ltd cannot guarantee that the e-mail or any attachments are free from viruses. NPL Management Ltd. Registered in England and Wales. No: 2937881 Registered Office: Teddington, Middlesex, United Kingdom TW11 0LW. -------------------------------------------------------------------
Andrew Gregory wrote:
I posted details of a problems on the google Python user group - someone emailed to say that I should send this to the distutils-sig. mailing list.
It concerns compiling a very simple C++ extension (as a test) on Mingw 2.0.0 for use with MSVC-compiled Python. Using linker option --enable-cxx did not help.
http://groups.google.co.uk/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=2830c89 c.0212101559.6ea63560%40posting.google.com&prev=/groups%3Fhl%3Den%26lr%3 D%26ie%3DUTF-8%26group%3Dcomp.lang.python
The output is shown below. The SWIG warnings seem to be normal - but it failed at the dllwrap stage.
Andrew Gregory.
C:\PyFiles\exMingw\MyCPP>python setup.py build --compiler=mingw32 running build running build_ext building '_pysimple' extension creating build creating build\temp.win32-2.2 creating build\temp.win32-2.2\Release C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python22\include -c pysimple_wrap.cxx -o build\temp.win32-2.2\Relea se\pysimple_wrap.o pysimple_wrap.cxx:180: warning: `swig_type_info* SWIG_TypeDynamicCast(swig_type_info*, void**)' defined but not used pysimple_wrap.cxx:192: warning: `swig_type_info* SWIG_TypeQuery(const char*)' defined but not used pysimple_wrap.cxx:374: warning: `void SWIG_addvarlink(PyObject*, char*, PyObject*(*)(), int (*)(PyObject*))' defined but not used pysimple_wrap.cxx:427: warning: `int SWIG_ConvertPtr(PyObject*, void**, swig_type_info*, int)' defined but not used pysimple_wrap.cxx:519: warning: `int SWIG_ConvertPacked(PyObject*, void*, int, swig_type_info*, int)' defined but not used writing build\temp.win32-2.2\Release\_pysimple.def creating build\lib.win32-2.2 C:\MinGW\bin\dllwrap.exe -mno-cygwin -mdll -static --entry _DllMain@12 --output-lib build\temp.win32-2.2\Release\lib_pys imple.a --def build\temp.win32-2.2\Release\_pysimple.def -s build\temp.win32-2.2\Release\pysimple_wrap.o -LC:\Python22\l ibs -lpython22 -o build\lib.win32-2.2\_pysimple.pyd build\temp.win32-2.2\Release\pysimple_wrap.o(.eh_frame+0x11):pysimple_wr ap.cxx: undefined reference to `__gxx_personalit y_v0' dllwrap: gcc exited with status 1 error: command 'dllwrap' failed with exit status 1
Looks like some lib is missing. Hard to tell which without a working MinGW installed :-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH _______________________________________________________________________ eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,... Python Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/
"M.-A. Lemburg" <mal@lemburg.com> writes:
ap.cxx: undefined reference to `__gxx_personalit y_v0' dllwrap: gcc exited with status 1 error: command 'dllwrap' failed with exit status 1
Looks like some lib is missing. Hard to tell which without a working MinGW installed :-)
That's not just "some lib", but a part of the C++ runtime. It may be as simple as setting LD_LIBRARY_PATH to include the location of the C++ runtimes shipped with mingw when linking. -- David Abrahams dave@boost-consulting.com * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
David Abrahams wrote:
"M.-A. Lemburg" <mal@lemburg.com> writes:
ap.cxx: undefined reference to `__gxx_personalit y_v0' dllwrap: gcc exited with status 1 error: command 'dllwrap' failed with exit status 1
Looks like some lib is missing. Hard to tell which without a working MinGW installed :-)
That's not just "some lib", but a part of the C++ runtime. It may be as simple as setting LD_LIBRARY_PATH to include the location of the C++ runtimes shipped with mingw when linking.
Patches are welcome. AFAIK, nobody is supporting MinGW for distutils, so you're on your own here. Could be that g++ needs to be used instead of gcc for compiling C++ code... at least that's what the CVS log suggests. The MinGW class has gcc hard-coded... -- Marc-Andre Lemburg CEO eGenix.com Software GmbH _______________________________________________________________________ eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,... Python Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/
"M.-A. Lemburg" <mal@lemburg.com> writes:
David Abrahams wrote:
"M.-A. Lemburg" <mal@lemburg.com> writes:
ap.cxx: undefined reference to `__gxx_personalit y_v0' dllwrap: gcc exited with status 1 error: command 'dllwrap' failed with exit status 1
Looks like some lib is missing. Hard to tell which without a working MinGW installed :-) That's not just "some lib", but a part of the C++ runtime. It may be as simple as setting LD_LIBRARY_PATH to include the location of the C++ runtimes shipped with mingw when linking.
Patches are welcome. AFAIK, nobody is supporting MinGW for distutils, so you're on your own here.
Could be that g++ needs to be used instead of gcc for compiling C++ code...
Yes, that is definitely the case.
at least that's what the CVS log suggests. The MinGW class has gcc hard-coded...
Easy fix, then! -- David Abrahams dave@boost-consulting.com * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
M.-A. Lemburg wrote
Andrew Gregory wrote:
I posted details of a problems on the google Python user group - someone emailed to say that I should send this to the distutils-sig. mailing list.
It concerns compiling a very simple C++ extension (as a test) on Mingw 2.0.0 for use with MSVC-compiled Python. Using linker option --enable-cxx did not help.
http://groups.google.co.uk/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=2830c89 c.0212101559.6ea63560%40posting.google.com&prev=/groups%3Fhl%3Den%26lr%3 D%26ie%3DUTF-8%26group%3Dcomp.lang.python
The output is shown below. The SWIG warnings seem to be normal - but it failed at the dllwrap stage.
Andrew Gregory.
C:\MinGW\bin\dllwrap.exe -mno-cygwin -mdll -static --entry _DllMain@12 --output-lib build\temp.win32-2.2\Release\lib_pysimple.a --def build\temp.win32-2.2\Release\_pysimple.def -s build\temp.win32-2.2\Release\pysimple_wrap.o -LC:\Python22\libs -lpython22 -o build\lib.win32-2.2\_pysimple.pyd build\temp.win32-2.2\Release\pysimple_wrap.o(.eh_frame+0x11): pysimple_wrap.cxx: undefined reference to `__gxx_personality_v0'
Looks like some lib is missing. Hard to tell which without a working MinGW installed :-)
try adding -lsupc++ to the linked with libs if that doesn't work try -lstdc++ HTH Norman
participants (4)
-
Andrew Gregory -
David Abrahams -
M.-A. Lemburg -
Norman Vine