I wan’t want to create a cross-plattform programm that embedds the python interpreter, and compile it with MinGW. But the Python Binary distribution provides no libraries for MinGW to link with (only python32.lib for Visual C++), and the Python Source package provides no support for compiling with MinGW.
I tried linking to python32.lib in Mingw with -lpython32 but it still generates errors like:
main.cpp: undefined reference to `_imp__Py_Initialize'
main.cpp: undefined reference to `_imp__Py_Finalize'
How do I link Python in MinGW? I really don’t want to switch to using Visual C++.
With nm and dlltool from binutils, you should be able to rebuild the library for gcc:
python_test.c:
Compile:
Test:
Edit: If you’d prefer to skip building this yourself on x64, you can download it for several versions from Christoph Gohlke’s Unofficial Windows Binaries for Python Extension Packages.
Edit: Here’s a Python version based on the existing function that’s distributed in Tools/msi/msi.py:
For example: