Friday, 25 July 2008

How to install eclipse+Qt 4+ MinGW

After trying to install Eclipse + QT integration +minGW with some trouble for the last 3 days I decided to put together a small guide to help newbies like me not to go through the same problems.
So you can follow the next step to install Eclipse under Windows vista with QT4.4.0 and minGW and its g++ libraries.

1. Download "Automated MinGW Installer" with filename “MinGW-5.1.4.exe” from http://sourceforge.net/project/showfiles.php?group_id=2435, Install MinGW-5.1.4.exe ( Notice you select and download “MinGW base tool” “g++ compiler”, and “MinGW make” during the installation)


Fig 1: MingGW installation.


Note: I selected the standard C:\MinGW\ path


2. Download "GNU Source-Level Debugger" from http://sourceforge.net/project/showfiles.php?group_id=2435, Filename is “gdb-6.8-mingw-3.tar.bz2” decompress it to the directory where you installed MinGW. (to decompress you may use the 7zip program) Please choose no when the decompression software asks you whether to cover the file with the same name.

Only the 2 files; gdb.exe and gdbserver.exe in the /bin/ have to be copied to the QT\4.4.0\bin\


3. Download "Qt/Windows Open Source Edition", filename “qt-win-opensource-4.4.0-mingw.exe” from http://trolltech.com/developer/downloads/qt/windows. Install it. It will put everything in C:\qt\4.4.0\

mingw message saying that it want to use mingw version 3, ignore the message. the version already install is newer and worked for me.



4. Download "Eclipse IDE for C/C++ Developers" filename “eclipse-cpp-ganymede-win32.zip” from http://www.eclipse.org/downloads/, decompress it to a directory no install involved, works directly from the exe file.



5. Download "Qt Eclipse Integration Downloads" with filename “qt-eclipse-integration-win32-1.4.0.exe” from http://trolltech.com/developer/downloads/qt/eclipse-integration-download, install it.

6. Set your system's Environment Variables.

Start\computer\system porperties\advanced system settings\ Environment Variables (under Vista)


Add C:\MinGW\bin and C:\Qt\4.4.0\bin to PATH
Add C:\MinGW\lib and C:\Qt\4.4.0\lib to LIB (create one if needed),
Add C:\MinGW\include and C:\Qt\4.4.0\include to INCLUDE (create one if needed),



Fig: Environment of vista.


Reboot your computer.(especially under windows XP or lower)
Note: If you forget this path the build of the debug libraries may give some errors.


7. In Start menu\All Applications\Qt by Trolltech v4.4.0 (OpenSource), please find Qt 4.4.0 (Build Debug Libraries) and execute it.

Note this will take around two hours on a celeron and few GBs on the hard disc where you installed Qt.



Fig: Building debug libraries and Qt\4.4.0\lib directory .


8. Now we are almost ready write a new Qt project in Eclipse. Just need to go to “Window\Preferences\Qt” to write the QT4 path “C:\QT\4.4.0\bin\” and “C:\QT\4.4.0\include\”


To run a program go to the main.cpp file select the green arrow \ run as local application.


Fig: Run eclipse with Qt project

It worked (this time) for me. It should work for you.

Have fun and all the best QTs


11 comments:

Anonymous said...

Is debugging and breakpoints working from within Eclipse? I have problems with source code not showing up.

sunnySan said...

No the breakpoints are not fully working.(can run under debug mode but does not follow the line by line sequence) It could due that the gdb.exe is only a beta version???

If you have another IDE(open source) which works well with breakpoints please let me know.

Thanks

Anonymous said...

I am using gdb 6.3.2 from http://surfnet.dl.sourceforge.net/sourceforge/mingw/gdb-6.3-2.exe

It works, but breakpoints in constructors does not work and multiple "step over" are needed to execute a complete line.

I am using the MinGW that installs automatic with Qt 4.4.0. It´s MinGW version 3.4.2.

I wonder if debugging in CDT can work as it should with a MinGW compiled debugger? In that case, what version?

sunnySan said...

Same problem. with the same version of Qt4.4 +Mingw + gdb.exe.

The around it is, to add QDebug() to show where the program fails. Not the best way...

If you solve the problem (e.g compiled gdb.exe with mingw) please let us know.

thanks

Roine said...

Changed to my real name :-)

I found a blog that explains why breakpoints is not working in constructors: http://vladimir_prus.blogspot.com/2007/11/breakpoints-in-constructors.html

I changed MinGW gdb version to 6.6 as this version is used in Wascana and should have been tested there (http://wascana.sourceforge.net/). Initial tests with 6.6 seams to work (apart from breaks in constructors).

As 6.8 has problems with Eclipse (no debug source code), i´ll stick with 6.6 for now. Let me know if it works for you to!

P.S Multiple "step overs" was due to option "Instruction stepping mode" button was enabled. D.S

sunnySan said...

Thanks Roine
I have just checked my latest config
with eclipse I used
gdb 6.8 and mingw 3.4.5 and Qt4.4

(to check cmd line: gdb -v , gcc -v)

The debug breakpoints not working.
Maybe I should change over to gdb 6.6 but I don't want to mess up with eclipse at the moment as I am working on a big project, and I m a bit short of time.

Hopefully the 6.10 version will come soon... so I can upgrade it.
But It is working (building/ compiling /running) enough to work on eclipse at the moment.

Anonymous said...

I can not print out this install guild from Firefox 3.0.1
It only shows the first page, all other pages is blank.

sunnySan said...

You are right, I have just try to print with firefox 3 and it's not printing all of it.
I also try with Chrome the new browser of google and it's printing fine.

Laila Hussein said...

This was a great tutorial! The only one which worked for me. Thanks so much!

Anonymous said...

Hello, thanks folks, the debugging problem is gone when i changed gdb version from 6.8 to 6.6. Strange but true..

MEDAMPUDI said...

Hi,

i am sorry to paste this post here but i had no other go.. your method was the nearest i could get to integrating and compiling qt properly.

I AM getting a serious problem at the portion http://thethoughtsofawanderingmind.blogspot.com/

Thank you for such a wonderful tutorial...