Before I saw many of the beginners of the QT Linux friends in using Qmake to compile the first HELLOQT or HelloWorld program times wrong , and always find the reason.
A few days ago I also met the same problem, I use the < proficiency in QT4 programming > book examples, the code with vim input after qmake, and then make the result error n line ,
Most of what is said about what is defined and so on, looked for a half-day discovery is just the beginning of a few lines #include<qtgui/. The > files are included in the error,
But not included or not, (later found on the internet a lot of people are also asking this question, but did not say that the solution), took a few hours time without fruit and finally.
Later downloaded the qtcreator and qdevelop, rewrite the program, compile and run are correct, also did not dig down.
Today on the internet inadvertently saw a post, suddenly think of their original written procedures (fortunately did not delete), a look suddenly.
Here is the original address:
Http://www.linuxsir.org/bbs/thread54238.html
I also reproduced the contents of the original post:
--------------------------------------------------------------------------------
Compiling QT programs under SuSE
Post 1:
Recently fascinated by swimming and QT, alive. But the QT program is built under SuSE, and the makefile that are automatically created with the steps in the QT documentation are not compiled. So my first reaction is to upgrade QT to 3.2, but after the upgrade but still can not compile, think not its solution, so patiently down to see the error message after make, and tracking to QT code inside see, found the error place is a C + + keyword place, and execute make after the first sentence is gcc-c * * * * * *, and then think of the past also met, as if GCC can only compile C program, to compile C + + must use g++, so open makefile, CC=GCC changed to cc=g++, save exit, the results QT program can be compiled That's tnnd.
Post 2:
Really ashamed, the reason for this problem is because my source file suffix name is not CPP, and then makefile think is C program, actually do not need to modify makefile can compile successfully. Cough, oneself or is too impetuous, so simple question unexpectedly, usually use C with habit, go to C + + even before the foundation have forgotten.
In addition, it is necessary to define the QTDIR environment variable before compiling the QT program, but I used bash to add the environment variable definition in. profile, but after I landed KDE, I lost the environment variable of Qtdir, it's strange that I should define it again. Qtdir=/usr/lib/qt3 on SuSE, if installed according to QT documentation, may be qtdir=/usr/local/.qt
--------------------------------------------------------------------------------
Because it is the use of Vim written code, save the time habitually saved. c file, the system default uses GCC instead of g++, of course, can not compile%>_<%.
No words no words, the C files are changed to CPP and make once, the smooth generation of executable files, and feel that the speed of such compilation than using Qtcreator or Qdevelop speed is much faster, (Qtcreator and qdevelop than the words, The latter compiles faster, but the editing function is weaker and personal.
In short, it is the cause of the problem to find out, but also a happy thing ha.
http://blog.csdn.net/lynfam/article/details/4727163
Vim+qmake compiling the sample program HELLOQT resolve the error problem (the file name must use. cpp, otherwise it will default to GCC compilation, of course)