PDA

View Full Version : Building Qt 4.4.3 with GCC 4.3.2 on Windows XP



shiyutang
26th October 2008, 09:55
1.Download GCC 4.3.2: http://www.tdragon.net/recentgcc/ click "TDM/MinGW Installer 1.808.3" to download and install;

2.Download Qt 4.4.3: ftp://ftp.trolltech.com/qt/source/qt-win-opensource-4.4.3-mingw.exe and install it. You will get a warning, just click OK to ignore;

3.In your System Environment's PATH, add YourMinGWDir\bin and YourQtDir\4.4.3\bin;

4.There are some bugs in Qt 4.4.3. Please fix them:

(1) Qt\4.4.3\src\corelib\arch\qatomic_windows.h: check line 386-392, they should be:
extern “C” {
__declspec(dllimport) long __stdcall InterlockedCompareExchange(long *, long, long);
__declspec(dllimport) long __stdcall InterlockedIncrement(long *);
__declspec(dllimport) long __stdcall InterlockedDecrement(long *);
__declspec(dllimport) long __stdcall InterlockedExchange(long *, long);
__declspec(dllimport) long __stdcall InterlockedExchangeAdd(long *, long);
}
Please modify them like below:
extern “C” {
__declspec(dllimport) long __stdcall InterlockedCompareExchange(volatile long *, long, long);
__declspec(dllimport) long __stdcall InterlockedIncrement(volatile long *);
__declspec(dllimport) long __stdcall InterlockedDecrement(volatile long *);
__declspec(dllimport) long __stdcall InterlockedExchange(volatile long *, long);
__declspec(dllimport) long __stdcall InterlockedExchangeAdd(volatile long *, long);
}

(2) Qt\4.4.3\src\corelib\io\qfsfileengine_win.cpp: check line 67-68, they should be:
#define SECURITY_WIN32
#include <security.h>
Add a line between them #include <subauth.h>, like these lines below:
#define SECURITY_WIN32
#include <subauth.h>
#include <security.h>

(3) Qt\4.4.3\src\gui\inputmethod\qwininputcontext_win. cpp: check line 500, it should be:
bool QWinInputContext::endComposition()
Please add a line above it: extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); ,like these lines blow:
extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
bool QWinInputContext::endComposition()

5.OK. It's time to compile. Click "Start"->"Qt by Nokia v4.4.3 (OpenSource)"->"Qt 4.4.3 Command Prompt", then enter "configure -debug-and-release -plugin-sql-sqlite -plugin-sql-odbc -qt-libpng -qt-libjpeg" and enter to configure. After several minutes, configure will done. And enter "mingw32-make" and enter to compile. It may take about 3 hours to make. It should take 4G harddisk place.

shirazk
27th October 2008, 19:16
Thank you, Shiyutang. This is a beeg help...the corrections particularly so. Only, it has not been 3 hours, but has now been compiling for more than twelve hours straight with no end in sight (perhaps I don't have as powerful a computer as you).

Thanks again.

Shirazk.

shiyutang
28th October 2008, 12:21
My computer is a ThinkPad T61, with a CPU Inter Core 2 Duo T7500, and 2GB memory.

gjshannon
1st November 2008, 17:20
I just wanted to say thanks for a great post. I was able to make the necessary modifications and build qt quite easily. But as another person mentioned is does take some time, so I basically started the build before going to bed, and it was finished in the morning. Anyway, thanks again.

gjshannon
1st November 2008, 17:52
A couple of relatively minor notes to keep in mind, especially for us newbies:

The primary purpose of this installation process is to update MinGW from gcc version 3.4.5 to gcc 4.3.2, a much more recent compiler but less tested than the "official" 3.4.5 release.

Purely for convenience, to temporarily keep the 3.4.5 libraries separate from the 4.3.2 libraries that I am now creating, I moved the source for Qt to a different directory than where I originally installed Qt when I used the installation program noted in this post.

If you do put the source in another location as I did, it will impact a number of items:
a) the environment variables used by the configure program have to be changed. These are "Lib" and "Include", and they were defined by the setup program to point to the original location for the source.
b) using the command prompt in the menus for the original Qt installation (menu "All Programs", "Qt by Nokia", "Qt Command Prompt") executes the qtvars.bat program that was generated by the installation program. Qtvars will define variables that point to the original folders for Qt, not the modified location I used afterwards.

I chose a quick and dirty way to address this, although I'm sure there are many other ways :
a) I redefined the environment variables to point to the new location of the source
b) I did not use the command prompt provided by the Qt menu. Instead, I opened a normal command prompt and changed the directory to the new location of the source.
c) After this was done I then executed the configure and minGW-make commands suggested by this post.

In the future, after I verify that the gcc 4.3.2 compilation does what I need it to do, then I may reinstall Qt to my location of choice and afterwords overwrite library files with those compiled using the gcc 4.3.2 compiler noted here.

One more small gotcha - when I cut and paste the external "C" code that corrects a Qt bug, the parentheses around the C character come up as weird characters and the compile fails. So if you see strange compiler errors, this may be the problem. Simply edit this class using a text editor and replace these weird characters that enclose the C with proper " symbols. When I did this everything worked great.

Hope this helps for us newbies.

yuniarto.rahardjo
24th November 2008, 07:32
Thanks for the information.
It will be great help.
:)

pastor
24th November 2008, 09:24
I had the same problem with Qt .4.4.3 & GCC3.4.5 on Windows.

2 shiyutang: Does Trolltech know about this issue?

shiyutang
1st December 2008, 08:52
I had the same problem with Qt .4.4.3 & GCC3.4.5 on Windows.

2 shiyutang: Does Trolltech know about this issue?

I have reported these bugs to Trolltech. But only got a reply: gcc 4 is not supported. They won't fix these bugs.

ComaWhite
14th March 2009, 19:00
Well maybe now Qt-4.5 has the open policy. Maybe they will finally accept it. They should reconsider adding support for it. We aren't in 2005/6 now Nokia. Please add support for it :( or accept patches that actually work :(

piotr.dobrogost
15th July 2009, 20:30
If you do put the source in another location as I did, it will impact a number of items:

You can solve this problem by using symbolic links to folders.
The idea is to have one "main" folder (c:\qt\qt) which is in fact a symbolic link to the version of qt you're using at the moment (c:\qt\qt-4.5.2-gcc3, c:\qt\qt-4.5.2-gcc4, c:\qt\qt-4.5.2-vc...).
To be able to quickly change current version of qt you can create a series of batch files using junction (http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx) tool from M$

Each batch file consists only from one line
junction c:\qt\qt c:\qt\qt-[some version]

You can also use this approach when you have more than one mingw version to be able to switch among them easily.