ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I installed the Qt libraries and wrote a small sample program, but when I try compiling it it does this:
Code:
$ qmake -project
$ qmake
$ make
g++ -c -pipe -g -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o qtorial.o qtorial.cpp
qtorial.cpp:1:24: error: QApplication: No such file or directory
qtorial.cpp:2:23: error: QPushButton: No such file or directory
qtorial.cpp: In function ‘int main(int, char**)’:
qtorial.cpp:6: error: ‘QApplication’ was not declared in this scope
qtorial.cpp:6: error: expected `;' before ‘app’
qtorial.cpp:7: error: ‘QPushButton’ was not declared in this scope
qtorial.cpp:7: error: expected `;' before ‘hello’
qtorial.cpp:8: error: ‘hello’ was not declared in this scope
qtorial.cpp:9: error: ‘app’ was not declared in this scope
qtorial.cpp: At global scope:
qtorial.cpp:4: warning: unused parameter ‘argc’
qtorial.cpp:4: warning: unused parameter ‘argv’
make: *** [qtorial.o] Error 1
This is the second time I tried Qt programming and I always get this.
I wonder what's the problem?
I installed the Qt libraries and wrote a small sample program, but when I try compiling it it does this:
Code:
$ qmake -project
$ qmake
$ make
g++ -c -pipe -g -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o qtorial.o qtorial.cpp
qtorial.cpp:1:24: error: QApplication: No such file or directory
qtorial.cpp:2:23: error: QPushButton: No such file or directory
qtorial.cpp: In function ‘int main(int, char**)’:
qtorial.cpp:6: error: ‘QApplication’ was not declared in this scope
qtorial.cpp:6: error: expected `;' before ‘app’
qtorial.cpp:7: error: ‘QPushButton’ was not declared in this scope
qtorial.cpp:7: error: expected `;' before ‘hello’
qtorial.cpp:8: error: ‘hello’ was not declared in this scope
qtorial.cpp:9: error: ‘app’ was not declared in this scope
qtorial.cpp: At global scope:
qtorial.cpp:4: warning: unused parameter ‘argc’
qtorial.cpp:4: warning: unused parameter ‘argv’
make: *** [qtorial.o] Error 1
This is the second time I tried Qt programming and I always get this.
I wonder what's the problem?
no Headers? it does seem to me as no headers are installed. try looking for devel or dev packages which should have the headers and any other need files for compiling.
did you installed it from source as make && make install (not the actual command), if so it should have installed header files. maybe gcc can't find headers as they are installed in none default place or gcc gets wrong flags. check the makefile used for the compile.
and check this folder /usr/include/qt3. and isn't there a official or none-official qt package for your system?
I installed like this, just like you said (Note that I shut down the computer between the two, make took longer than I expected and it was quite late by then, but I don't think this could have affected anything):
Code:
$ make
$ make install
I do have a /usr/include/qt3 folder, and it seems to be full of header files (.h).
Apparently Qt 4 uses what you had in your first post (see http://doc.trolltech.com/4.0/tutorial-t1.html). However, your using Qt 3 which does what I suggested (see http://doc.trolltech.com/3.0/tutorial1-01.html). Make sure you followed the steps for Qt 3, for installation, configuration, compiling, etc, as it seems you followed the Qt 4 Hello World tutorial its possible you followed the Qt 4 version of other steps.
i was just gonna say this. probably this is why gcc can't find it. however in C++, #include<QApplication> style includes. maybe we can't use gcc rightly.
and MTK358, i tried it with QT4 and it worked. maybe you are using wrong version of qt to compile.
qmake -v should show you the QT version and where it is.
i was just gonna say this. probably this is why gcc can't find it
He/she is using g++, not gcc. And my guess, as mentioned above, is that he/she followed the wrong tutorial/setup/configuration guide (used Qt 4 instead of Qt 3, as he/she did for the tutorial).
He/she is using g++, not gcc. And my guess, as mentioned above, is that he/she followed the wrong tutorial/setup/configuration guide (used Qt 4 instead of Qt 3, as he/she did for the tutorial).
gcc is umbrella term for Gnu Compiler Collection (GCC).
Anyway it didn't work and then I tried apt-get install qt-dev*, maybe that's the problem.
Also I am going to get openSUSE 11.2 tomorrow, and I hope to install it instead of Debian. I would really want to know how to install Qt4 (not 3) correctly there and have it work.
But it would be nice to get some Qt practice on Debian toworrow while waiting for the approximately 4.7GB download.
I see you are wondering whether I am a "he" or a "she", I am a "he".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.