Thursday, August 28th 2008, 5:24pm UTC+1

You are not logged in.

  • Login
  • Register

1

Thursday, March 20th 2008, 10:19pm

Qt v4.3.4 + NetBeans IDE 6.0.1 + Windows

Greetings!
I'm trying to program under Windows, since I'm having some unsolved hardware issues with Kubuntu.
Now, I want to run Qt projects using NetBeans, but I'm having plenty of errors when trying to Build them.
If you know how to set all to work, if you already have it working, please share it here.
All help appreciated!

EDITED: see Tutorial posted!

This post has been edited 1 times, last edit by "BernardoLG" (May 4th 2008, 12:54pm)

  • Go to the top of the page

2

Friday, March 21st 2008, 8:53am

Cygwin vs MinGW

Seems to be that many of the problems are because of the Cygwin NetBeans is supposed to need.

I'm trying to use MinGW for the NetBeans, and I've been able to advance a bit on compiling Qt projects.

If you already know how, don't hesitate on posting it here.
  • Go to the top of the page

3

Saturday, April 5th 2008, 10:36am

Qt v4.3.4 + NetBeans IDE 6.0.1 + Windows + MinGw + CygWin

Although this note was written for netbeans 6.0 it is equally valid for 6.1.

I have installed netbeans 6.0 under SuSE 10.3 plus Qt and got it working with some minor changes of the default netbeans settings. Under Windows it's a whole different story. The major difficulty was to figure out how to have mingw and cygwin coexist in Windows, and get Microsoft Visual Studio out of the way. (remark: Visual Studio is documented to work only in the commercial version of Qt).

The outline of what I did is here:
1. Install Qt as described in the Installation docs from Qt. Basically: download the two 4.3.4 files you find here: http://trolltech.com/developer/downloads/qt/windows (scroll down that page until you find http or ftp download sites).

Double-click the qt-win-opensource-4.3.4-mingw.exe file. This prompts you to download mingw. Install it to C:\Mingw.

Then proceed installing Qt to C:\Qt\4.3.4.

This basically gives you entries in the Windows Start Menu.

2. Build Qt

Open the Qt 4.3.4 Command Prompt from Windows Start.

You get a DOS-Box console window where you have good environments settings for Qt and MinGw to work together. In my case, when I type PATH in the console it get

PATH=C:\Qt\4.3.4\bin;C:\MinGW\bin;C:\WINDOWS\System32

It is crucial that you do not have a link to cygwin\bin somewhere in here only for the next two steps.

a) Now you can configure the Qt system for being compiled by typing

C:\Qt\4.3.4> configure -platform win32-g++

This took a while (15 min)

b) Compile and make it:

make
or
mingw32-make

This took 3 hours or more.

When this has completed you are ready to get into the netbeans stuff.

3. Netbeans

The best way is to start netbeans from the Qt-command window which has the minimalistic PATH settings by adding cygwin at the end of the path:

add cywin to the PATH
C:\Qt\4.3.4> PATH=%PATH%;C:\CygWin\bin

start netbeans:
C:\Qt\4.3.4> "C:\Program Files\Netbeans 6.0.1\bin\netbeans"

Change the above lines as required by your cygwin and netbeans installations. By doing this we ensure that the mingw compiler is found before the g++ that you might have on your cygwin, and that netbeans will find a sh.exe later when we run our programs.

In Netbeans select Tools->Options->C++
- In Build Tools you select the make tool to be mingw32-make
- In Code Assistance, C++ Compiler, you include all the subdirectories of C:\Qt\4.3.4\include that you need.
In my case I started out with C:\Qt\4.3.4\include,C:\Qt\4.3.4\include\Qt, C:\Qt\4.3.4\include\QtGui, C:\Qt\4.3.4\include\UITools, C:\Qt\4.3.4\include\QtCore.

Note: The inclusion of C:\Qt\4.3.4\include (although it does not contain any .h files) is mandatory for code completion to work (see comments on netbeans 6.1 below)

This step results in netbeans to get rid of the red underlines under lines like #include <QApplication>. They really won't matter because we will use Qt's make anyway, which has its own include path setting. But let's do this anyway.

4. New project in netbeans

Now let's get a new project in netbeans:
File-New Project->C++ Application and choose your project directory.

Don' t try to build it (yet).

5. Make the new project Qt-ready

Go back to the command line, navigate to your netbeans project directory. Example:
C:\Qt\4.3.4.> cd C:\_E\Work\C++\QtHello

C:\_E\Work\C++\QtHello> qmake -project CONFIG+=console
This creates a qtHello.pro file. The config option is essential when you want to see output from your cout and printf's.!!!!!!!!!

and

C:\_E\Work\C++\QtHello> qmake

qmake has to be done every time you add new source files to your project or rename them.

You should be able to build your program from netbeans now. (F11)

What needs to be done is to get Netbeans run your program with <F6>

6. Get it "running".

Open the project settings and change the Linker Output from dist/debug/MinGW-Windows/qtHello to debug/qtHello.

(Project Properties->Linker->General)

Now you can do a <F6> and your program will be built and run anytime you change your source code.


IMPORTANT: Now you can work in netbeans as usual with Java, etc. Don't forget the qmake when you add files to your project.

7. Code completion

What I have not yet figured out is how to get code completion working fully in Windows netbeans 6.0.1. In my Linux 6.0 installation Qt source code has full code completion. The Windows Qt code seems to be much more complex than that of Linux and code completion is not working fully at the moment. The netbeans developer team was extremely helpful in this respect and it seems code completion for Qt will work in netbeans 6.1 release (not in the current beta).

NEW: Install netbeans 6.1. It has full code completion both under Linux and Windows

I hope this helps.

Cheers,

Wolfgang

This post has been edited 13 times, last edit by "polzleitner" (May 4th 2008, 10:31am)

  • Go to the top of the page

4

Saturday, May 3rd 2008, 9:31pm

RE: Qt v4.3.4 + NetBeans IDE 6.0.1 + Windows + MinGw + CygWin

This've got to be the MOST complete tutorial for installing all of it!

Going to try it right now!

Thanks so much for the time to post it and help! :) :) :) :) :)
  • Go to the top of the page

datuputi

Beginner

Posts: 2

Location: Mississauga

Occupation: Software Developer

5

Sunday, May 4th 2008, 2:30am

RE: Qt v4.3.4 + NetBeans IDE 6.0.1 + Windows + MinGw + CygWin

First off I'd llike to say Great Tutorial ! The best one I've found on this subject.
But I have one problem, I can't compile my "Hello World" application from inside Netbeans. I've followed your tutorial step-by-step (twice) and no matter what I can't get it to compile, inside Netbeans but works fine from the command line. I've pasted the output from my build below and highligthed the error, I've also pasted the file listing. The main problem is that when compiled the .o files are not being placed the the debug or release directories they are being named debugqthelloworld.o and releaseqthelloworld.o, but the mingw32-make.exe is looking for the files in debug and release directories. I realize that this is an issue related to path separators but not sure why or where this is happening. If anybody as any ideas it would be greatly appreciated. Thanks.

----------- build output----------------
Running "C:\Qt\MinGW\bin\mingw32-make.exe -f Makefile CONF=Debug" in C:\Qt\dev\qtHelloWorld
C:/Qt/MinGW/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[1]: Entering directory `C:/Qt/dev/qtHelloWorld'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\4.3.4\include\QtCore" -I"..\..\4.3.4\include\QtCore" -I"..\..\4.3.4\include\QtGui" -I"..\..\4.3.4\include\QtGui" -I"..\..\4.3.4\include" -I"." -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\4.3.4\mkspecs\win32-g++" -o debug\qthello.o qthello.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\qtHelloWorld.exe debug/qthello.o -L"c:\Qt\4.3.4\lib" -lQtGuid4 -lQtCored4

g++.exe: debug/qthello.o: No such file or directory
mingw32-make.exe[1]: *** [debug\qtHelloWorld.exe] Error 1
mingw32-make.exe[1]: Leaving directory `C:/Qt/dev/qtHelloWorld'
C:\Qt\MinGW\bin\mingw32-make.exe: *** [debug] Error 2
Build failed. Exit value 2.

---------------- file listing ---------------------
Directory of C:\Qt\dev\qtHelloWorld

03/05/2008 09:18 PM <DIR> .
03/05/2008 09:18 PM <DIR> ..
03/05/2008 09:18 PM <DIR> debug
03/05/2008 09:18 PM 5,838 debugqthello.o
03/05/2008 09:18 PM 5,209 Makefile
03/05/2008 09:18 PM 4,537 Makefile.Debug
03/05/2008 09:18 PM 4,582 Makefile.Release
03/05/2008 09:18 PM <DIR> nbproject
03/05/2008 09:18 PM 249 qthello.cpp
03/05/2008 09:18 PM 328 qtHelloWorld.pro
03/05/2008 09:18 PM <DIR> release

This post has been edited 2 times, last edit by "datuputi" (May 4th 2008, 2:35am)

  • Go to the top of the page

6

Sunday, May 4th 2008, 10:18am

RE: Qt v4.3.4 + NetBeans IDE 6.0.1 + Windows + MinGw + CygWin

Looks like your debug/qthello.o gets converted to debugqthello.o. Then it is not found by other programs which think it's under debug/qthello.o. This has happened to me when the g++ that was executed was not the mingw one, but the cygwin version. Try the following: from the shell where you start netbeans, type PATH to see what your PATH is. Also look on your system for another g++ program (probably C:\cygwin\bin, or wherever you might have a cygwin installation). I am pretty sure you have the wrong g++ in your PATH.

Sometimes running a "make clean", or "mingw32-make clean" helps.

W.

This post has been edited 2 times, last edit by "polzleitner" (May 4th 2008, 10:19am)

  • Go to the top of the page

7

Sunday, May 4th 2008, 5:58pm

Working just dandy!

Installation successful, although it took about 8 hours on my PC.
Compiling and running just dandy!
Going to try some Qt examples and try to code some.
This should be moved to the "Tutorials" section 8)
Thanks again Wolfgang!

Keep posting!
  • Go to the top of the page

datuputi

Beginner

Posts: 2

Location: Mississauga

Occupation: Software Developer

8

Wednesday, May 7th 2008, 4:43am

RE: Qt v4.3.4 + NetBeans IDE 6.0.1 + Windows + MinGw + CygWin

Polzleitner, thank you ! I finally got it working ! I can compile and run from inside Netbeans. I uninstalled all dev tools (make, g++, gcc, etc) from my Cygwin bin directory and launch Netbeans as per your suggestion. Again thanks.

Another issue now that I have it working. What application do you use for debugging (stepping thru code and such) ? I currently have gdb install on Cygwin but it seems to be very slow and and has even caused my Netbeans to stop responding. Any recommendations.

Thanks
  • Go to the top of the page

9

Friday, May 16th 2008, 1:13am

Error

I'm new in C++ and Qt.

Two questions, which is the usefulness of the cygwin in those steps?

It's happening the following errors when compiling :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
C:/MinGW/bin/mingw32-make -f Makefile.Debug

mingw32-make[1]: Entering directory `C:/Documents and Settings/Conrado/Meus documentos/NetBeansProjects/Application_1'

gcc -c -g -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\4.4.0\include\QtCore" -I"c:\Qt\4.4.0\include\QtCore" -I"c:\Qt\4.4.0\include\QtGui" -I"c:\Qt\4.4.0\include\QtGui" -I"c:\Qt\4.4.0\include" -I"." -I"c:\Qt\4.4.0\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.0\mkspecs\win32-g++" -o debug\newmain.o newmain.c

In file included from c:/Qt/4.4.0/include/QtCore/qnamespace.h:1,

                 from c:/Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:47,

                 from c:/Qt/4.4.0/include/QtCore/qobjectdefs.h:1,

                 from c:/Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobject.h:49,

                 from c:/Qt/4.4.0/include/QtCore/qobject.h:1,

                 from c:/Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:47,

                 from c:/Qt/4.4.0/include/QtCore/qcoreapplication.h:1,

                 from c:/Qt/4.4.0/include/QtGui/../../src/gui/kernel/qapplication.h:47,

                 from c:/Qt/4.4.0/include/QtGui/qapplication.h:1,

                 from c:/Qt/4.4.0/include/QtGui/QApplication:1,

                 from newmain.c:1:

c:/Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:56: error: syntax error before "namespace"

c:/Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:60: error: syntax error before '{' token

c:/Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:127: warning: return type defaults to `int'

c:/Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h: In function `Q_DECLARE_FLAGS':

c:/Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:128: error: `Qt' undeclared (first use in this function)

c:/Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:128: error: (Each undeclared identifier is reported only once

c:/Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:128: error: for each function it appears in.)

c:/Qt/4.4.0/include/QtCore/../../src/corelib/global/qnamespace.h:128: confused by earlier errors, bailing out

mingw32-make[1]: *** [debug/newmain.o] Error 1

mingw32-make[1]: Leaving directory `C:/Documents and Settings/Conrado/Meus documentos/NetBeansProjects/Application_1'

mingw32-make: *** [debug] Error 2


This code i'm trying to compile

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <QApplication>
 #include <QPushButton>

 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);

     QPushButton hello("Hello world!");
     hello.resize(100, 30);

     hello.show();
     return app.exec();
 }



Thanks

This post has been edited 1 times, last edit by "ConradoQG" (May 16th 2008, 1:16am)

  • Go to the top of the page

Rate this thread