20

Is it possible to build Python interpreter from source with Mingw and gcc on Windows 7? And I would like to biuld a 64bit version.

If a 64bit Python (gcc Mingw) version is available for download please let me know, I would use that also. At the end I still would like to compile it with gcc and mingw.

2
  • Download the sources, read the docs, and run the compiler with appropriate flags. This doesn't apply only to MinGW :) Commented Mar 12, 2013 at 15:31
  • 3
    @StoryTeller your name is aptly chosen. Python does not build out of the box with MinGW, let alone for Win64. Commented Mar 12, 2013 at 15:53

2 Answers 2

8

First off, you do not need to build Python with MinGW-w64 to link to it and embed a interpreter. Just extract the msi installer, and use the prebuilt DLL. Note you'll have to be careful not to mix msvcr[t|90].dll objects, but I've never seen that be a real issue personally.

MinGW-w64 gcc/ld should be able to link to DLL's directly, otherwise you'll have to use gendef to create a .def file and dlltool to create an import library.

Secondly, there's a patchset to build Python with MinGW, but I'm not sure about its 64-bit compatibility.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for the reply. The reason for this, is I would like to compile Quantum-Gis for 64 bit with mingw and gcc. Quatum-Gis have capability for utilising plugins written in python or c++. For this I need Sip and PyQt4 in 64bit for Win7. I went through the gendef/nm process to create the libpython27.a file. I started to build Sip with Mingw and gcc and Python 2.7.3 all in 64bit, successfully, I also could test Sip in a python console. I successfully compiled PyQt4 and install it, but when testing it in a python console it just fails.
I don't know how to debug this failure? Because of this failure I reasoned that maybe I need to compile Python 2.7.3 with mingw and gcc in 64bit. In your opinion, if I download pre-build 64 bit Sip and PyQt4 binaries that is build with MSVC, would I have problems later on with other python scripts/plugins written against these binaries?
@TheunsHeydenrych That I don't know. I would suggest asking the [email protected] mailing list, where a couple of people use Python with MinGW-w64. All I do is link gdb to Python, which works as I described ;-).
Searching the tracker for 'mingw' returns about 50 open issues and 100 closed issues. Some of the recent open issues might be helpful.
Personally, I used a mingw64 build that already includes a version of python 2.7.
4

You may try this repository:

hg clone https://bitbucket.org/puqing/python-mingw

It is a copy of the official repository but contains some modification to make it compile with mingw. Enter PC/MinGW directory:

cd PC/MinGW && make

Not sure if it compiles in win64, but with win32 and msys it should work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.