The compile steps with Qt4 are:
Note on Code Completion:
Go to Project->Properties->C/C++ General->Paths and Symbols
In the GNU C++ tab add the following paths (depending on the version of QT)
/usr/local/Trolltech/Qt-4.4.1/include
/usr/local/Trolltech/Qt-4.4.1/include/QtGui
/usr/local/Trolltech/Qt-4.4.1/include/QtSql (if you use sql)
The rebuild code index
This will take care of code competion and things like Q_OBJECT being not recognized
- qmake -project [generates a .pro file based on the files you have in the root directory]
- qmake [genrates the Makefile from the .pro file]
- make [gnu make that uses the Makefile to generate your project as a *.app folder]
- Fire up eclipse and choose File->New->C++ Project
- Uncheck 'use default location' and browse to the root of your code tree
- Enter a Project name e.g. ChhobiQT
- Pick Empty Project (leave MavOSX GCC as is)
At this stage eclipse will find your files/subdirectories and try and compile and probably give you an error. Ignore this smart ass behavior or uncheck Project->Build automatically - Project->Properties (If this is grayed out, make sure to click and highlight ChhobiQT)
- ->C/C++ Build : Uncheck 'Generate Makefiles automatically'
- 'Build directory' set it to the variable ${project_loc}
- Run->External Tools Dialog
- Under program create a new entry and set:
Name : qmake1
Location : location of qmake on your system e.g. /usr/local/Trolltech/Qt-4.4.0/bin/qmake
Working directory : ${project_loc}
Arguments : -project
This 'External program' will enable you to generate a *.pro file when you need it - Make an identical entry but name is qmake2 and make Arguments blank
This entry will let you generate a Makefile when you add files to the project - Now click Run->External Tools->qmake1 and then qmake2
- Hit F5 to refresh the Project explorer
You should see a .pro file and a Makefile - Project->Build Project
You should now have a *.app file - Run->Run
Your application should now run
Note on Code Completion:
Go to Project->Properties->C/C++ General->Paths and Symbols
In the GNU C++ tab add the following paths (depending on the version of QT)
/usr/local/Trolltech/Qt-4.4.1/include
/usr/local/Trolltech/Qt-4.4.1/include/QtGui
/usr/local/Trolltech/Qt-4.4.1/include/QtSql (if you use sql)
The rebuild code index
This will take care of code competion and things like Q_OBJECT being not recognized
I'm just tinkering with Qt for the Mac. I'm having some trouble... qmake does not generate a makefile; instead it generates a .xcodeproj file. Any clues on how I can get it to use Makefiles under MacOS X?
ReplyDeletetry
ReplyDeleteqmake -spec macx-g++ -macx file.pro
THANKS THANKS THANKS!!! :-)
ReplyDeleteyou saved me a lot of pain
marco
Hi.
ReplyDeleteI have followed your steps and I get a working .app file and the app works fine. BUT I don't get code completion in Eclipse. I have no error highlights but some q_object highlights.
Any Ideas?
Using cdt 5.0.2.
thanks
Hi,
ReplyDeleteI'm assuming you did the last step at the end. You will have to tailor the paths to your local install of QT. And (**this is important**) QT should be compiled with symbols on. For some reason the actual install of QT I use 4.4.4 does not work, I link to an older version 4.4.1 I forget exactly what it is, but I think you have to **configure as debug** which generates symbol tables. I don't know enough about the internals to explain the mechanism.
Best
-K
thanks, it works!
ReplyDeleteHI,
ReplyDeleteFirst of all thanks for creating this helpful document.
I have follow your steps but when qmake1 command to create .pro file i found the below error.
ERROR :
make: *** No rule to make target `all'. Stop.
While someone please guid me to solve this issue.
This is the first tutorial that actually works. Under Linux too. Thanks!
ReplyDelete