Posted on June 4, 2006 at 1:28 pm

Installing PyQT4 GPL with Mingw on Windows

I’ve been trying to get the latest PyQT4 GPL snapshot with QT 4.1.2 working with Mingw32 on a windows box. Had a little bit of trouble in the process, so writing this log so that anyone else who tries this wouldn’t end up wasting time like I did :)

Ingredients:
1) Python 2.4.3
2) Mingw
3) QT4 GPL src for Windows (get the zip file, not the exe )
4) PyQt4

Start with compiling QT. extract the zip file to some directory and then go to that directory and run “configure -prefix C:\QT\4.1.2″ Its also a good idea to append a “-release” flag to save time by avoiding building the debug version of the libraries.

Once done, run “mingw32-make” and then “mingw32-make install”.

We also need to set two environment variables, QTMAKESPEC and QTDIR

Set QTMAKESPEC to “win32-g++” (without the quotes)
and set QTDIR to the prefix directory specified to configure (In my case, it was “C:\QT\4.1.2″, again without quotes)

Also remember to add the install-path\bin (“C:\QT\4.1.2\bin”) to the PATH

So we’ve got QT installed.

Next up, getting PyQT4 working. extract the PyQt4 zipfile to some directory and run “configure.py”. For some reason, this doesn’t work. PyQt4 looks for libQtCore4.a in “C:\QT\4.1.2\lib” but it isn’t created by the QT.

So, we get pexports and create it.
Download the zip file and extract pexports.exe to the MingGW bin directory.

Then, fire up command prompt and go to the “C:\QT\4.1.2\bin” directory.
type in the following commands

pexports QtCore4.dll > QtCore4.def
dlltool –dllname QtCore4.dll –def QtCore4.def –output-lib libQtCore4.a
move libQtCore4.a ..\lib

Now just go to the PyQT directory
run
configure.py
mingw32-make
mingw32-make install

Thats it! We’ve got PyQT installed, provided you did’nt get any further errors :)
Try running a hello world program from the PyQT4 examples directory.

There’s only one problem I’ve encountered. I haven’t been able to get QT Designer to work.
But I can always go back to Linux for that :)

8 Responses to “Installing PyQT4 GPL with Mingw on Windows”

  1. spicymixer on June 20th, 2006 at 7:47 AM says:

    Hi, You made it sound very simple. But I am stuck at configuring QT. I using cygwin, g++ and mingw, and when trying to configure qt, I get the following.

    In file included from generators/makefiledeps.cpp:30:
    ../mkspecs/win32-g++/qplatformdefs.h:14:19: tchar.h: No such file or directory
    ../mkspecs/win32-g++/qplatformdefs.h:16:20: direct.h: No such file or directory
    generators/makefiledeps.cpp: In member function `bool QMakeSourceFileInfo::findD
    eps(SourceFile*)':
    generators/makefiledeps.cpp:370: error: `::_read’ has not been declared
    generators/makefiledeps.cpp:372: error: `::_close’ has not been declared
    generators/makefiledeps.cpp: In member function `bool QMakeSourceFileInfo::findM
    ocs(SourceFile*)':
    generators/makefiledeps.cpp:675: error: `::_read’ has not been declared
    generators/makefiledeps.cpp:677: error: `::_close’ has not been declared
    mingw32-make: *** [makefiledeps.o] Error 1
    Building qmake failed, return code 2

    tried adding the path in INCLUDE Env variable, still no go. Is there anyway you can help me out ?

  2. Jeethu Rao on June 21st, 2006 at 8:18 PM says:

    tchar.h is a Windows specific header which cygwin lacks. Looks like the g++ used here is the one from Cygwin. Oh yeah, you can pass the -mno-cygwin flag to the cygwin g++ to enable cross compiling of native win32 apps (i.e apps which don’t depend on cygwin.dll) but I have no clue about how to coax configure to pass this flag to g++.
    I’d recommend that you uninstall Cygwin and try it with just mingw and msys. Another thing worth giving a shot is to remove the cygwin bin directory from the path and making sure that the mingw32 bin directory is in the path.

  3. spicymixer on June 27th, 2006 at 9:54 AM says:

    ty I did get little further with that. Now got stuck again :-)
    First of all windres did go forward saying “no resource”. So used rc and then used windres manually to create .o files from res file. But this one file qtaccessiblewidgetsd_resource.rc is creating issue. I guess because of long file name.
    err: windres: unexpected version string length 32 != 32 + 4
    This is what I get.. and I found no reference for this.. you got any solution.

  4. Jeethu Rao on June 27th, 2006 at 12:48 PM says:

    I’m not quite sure why it isn’t working for you. Just today I installed Qt4.1.4 GPL with almost no trouble. I’ll probably post a detailed log later. Maybe I can help you over IRC. I usually hang out of #python on freenode with the nick “xjeethux”.

  5. Joel on July 3rd, 2006 at 5:09 PM says:

    How come you know all these stuff ?

  6. TAN THIAM HUAT on February 1st, 2008 at 9:21 AM says:

    I work with 4.3.3, but encounter errors.

    I have tried to compile this qt-win-opensource-src-4.3.3, but always encounter errors. Could you help?
    I have put everything under this directory E:\TTH\
    I follows the instructions as in http://jeethurao.com/blog/?cat=11

    Start with compiling QT. extract the zip file to some directory and then go to that directory and run “configure -prefix E:\TTH\QT\4.3.3? — no errors
    mingw32-make — errors come

    Creating library file: e:\TTH\Qt\qt-win-opensource-src-4.3.3\lib\libQtCored4.a
    ./tmp\obj\debug_shared\qfsfileengine_win.o: In function `Z8readLinkRK7QString':
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoInitialize@4′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `IID_IPersistFile’
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoUninitialize@0′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoInitialize@4′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `IID_IPersistFile’
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoUninitialize@0′
    ./tmp\obj\debug_shared\qfsfileengine_win.o: In function `ZN13QFSFileEngine4linkE
    RK7QString':
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoInitialize@4′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `IID_IPersistFile’
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoUninitialize@0′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoInitialize@4′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `IID_IPersistFile’
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoUninitialize@0′
    ./tmp\obj\debug_shared\quuid.o: In function `ZN5QUuid10createUuidEv':
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/plugin/quuid.cpp:409: undefine
    d reference to `CoCreateGuid@4′
    ./tmp\obj\debug_shared\qeventdispatcher_win.o: In function `ZN28QEventDispatcher
    Win32Private16doWsaAsyncSelectEi':
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/kernel/qeventdispatcher_win.cp
    p:388: undefined reference to `WSAAsyncSelect@16′
    collect2: ld returned 1 exit status
    mingw32-make[2]: *** [..\..\lib\QtCored4.dll] Error 1
    mingw32-make[2]: Leaving directory `E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/co
    relib’
    mingw32-make[1]: *** [debug-all] Error 2
    mingw32-make[1]: Leaving directory `E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/co
    relib’
    mingw32-make: *** [sub-corelib-make_default-ordered] Error 2
    E:\TTH\Qt\qt-win-opensource-src-4.3.3>

    I did set those Environment Variables properly.
    We also need to set two environment variables, QTMAKESPEC and QTDIR

    Set QTMAKESPEC to “win32-g++” (without the quotes)
    and set QTDIR to the prefix directory specified to configure (In my case, it was “E:\TTH\QT\4.3.3?, again without quotes)

    Also remember to add the install-path\bin (”E:\TTH\QT\4.3.3\bin”) to the PATH

    I want to do

    >>> from qt import *

    but got errors, is it true that I need to install the QT correctly first?

  7. TAN THIAM HUAT on February 1st, 2008 at 9:21 AM says:

    I work with 4.3.3, but encounter errors.

    I have tried to compile this qt-win-opensource-src-4.3.3, but always encounter errors. Could you help?
    I have put everything under this directory E:\TTH\
    I follows the instructions as in http://jeethurao.com/blog/?cat=11

    Start with compiling QT. extract the zip file to some directory and then go to that directory and run “configure -prefix E:\TTH\QT\4.3.3? — no errors
    mingw32-make — errors come

    Creating library file: e:\TTH\Qt\qt-win-opensource-src-4.3.3\lib\libQtCored4.a
    ./tmp\obj\debug_shared\qfsfileengine_win.o: In function `Z8readLinkRK7QString':
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoInitialize@4′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `IID_IPersistFile’
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoUninitialize@0′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoInitialize@4′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `IID_IPersistFile’
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1326:
    undefined reference to `CoUninitialize@0′
    ./tmp\obj\debug_shared\qfsfileengine_win.o: In function `ZN13QFSFileEngine4linkE
    RK7QString':
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoInitialize@4′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `IID_IPersistFile’
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoUninitialize@0′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoInitialize@4′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoCreateInstance@20′
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `IID_IPersistFile’
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/io/qfsfileengine_win.cpp:1420:
    undefined reference to `CoUninitialize@0′
    ./tmp\obj\debug_shared\quuid.o: In function `ZN5QUuid10createUuidEv':
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/plugin/quuid.cpp:409: undefine
    d reference to `CoCreateGuid@4′
    ./tmp\obj\debug_shared\qeventdispatcher_win.o: In function `ZN28QEventDispatcher
    Win32Private16doWsaAsyncSelectEi':
    E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/corelib/kernel/qeventdispatcher_win.cp
    p:388: undefined reference to `WSAAsyncSelect@16′
    collect2: ld returned 1 exit status
    mingw32-make[2]: *** [..\..\lib\QtCored4.dll] Error 1
    mingw32-make[2]: Leaving directory `E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/co
    relib’
    mingw32-make[1]: *** [debug-all] Error 2
    mingw32-make[1]: Leaving directory `E:/TTH/Qt/qt-win-opensource-src-4.3.3/src/co
    relib’
    mingw32-make: *** [sub-corelib-make_default-ordered] Error 2
    E:\TTH\Qt\qt-win-opensource-src-4.3.3>

    I did set those Environment Variables properly.
    We also need to set two environment variables, QTMAKESPEC and QTDIR

    Set QTMAKESPEC to “win32-g++” (without the quotes)
    and set QTDIR to the prefix directory specified to configure (In my case, it was “E:\TTH\QT\4.3.3?, again without quotes)

    Also remember to add the install-path\bin (”E:\TTH\QT\4.3.3\bin”) to the PATH

    I want to do

    >>> from qt import *

    but got errors, is it true that I need to install the QT correctly first?

  8. Goran on May 23rd, 2008 at 2:47 PM says:

    Just delete lib and include from environment
    SET LIB=
    SET INCLUDE=

Leave a Reply