LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-10-2009, 12:06 PM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Unhappy Can't compile Qt project


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?

This is the code:

Code:
#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QPushButton hello("Hello, World!");
	hello.show();
	return app.exec();
}
 
Old 11-10-2009, 12:21 PM   #2
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by MTK358 View Post
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?

This is the code:

Code:
#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QPushButton hello("Hello, World!");
	hello.show();
	return app.exec();
}
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.
 
Old 11-10-2009, 12:24 PM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
This is what I downloaded (the Framework Only section):

http://qt.nokia.com/downloads
 
Old 11-10-2009, 01:45 PM   #4
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by MTK358 View Post
This is what I downloaded (the Framework Only section):

http://qt.nokia.com/downloads
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?
 
Old 11-10-2009, 01:51 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
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).

Last edited by MTK358; 11-10-2009 at 01:53 PM.
 
Old 11-10-2009, 02:49 PM   #6
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
I dont know anything about Qt, but use these instead of the headers you have (which, as the compiler says, dont exist)
Code:
#include <qapplication.h>
#include <qpushbutton.h>
 
Old 11-10-2009, 03:02 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Same thing.

But anyway it shows the headers capitalized everywhere.
 
Old 11-10-2009, 03:10 PM   #8
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
No, it doesnt.

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.

Last edited by nadroj; 11-10-2009 at 03:11 PM.
 
Old 11-10-2009, 03:28 PM   #9
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by nadroj View Post
I dont know anything about Qt, but use these instead of the headers you have (which, as the compiler says, dont exist)
Code:
#include <qapplication.h>
#include <qpushbutton.h>
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.

you are trying to complite it with QT3.
 
Old 11-10-2009, 03:35 PM   #10
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
Quote:
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).
 
Old 11-10-2009, 03:54 PM   #11
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by nadroj View Post
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).

and definitely she is using wrong QT version.
 
Old 11-10-2009, 04:10 PM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
But the page where I downloaded it says Qt4!?!

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".

Last edited by MTK358; 11-10-2009 at 04:11 PM.
 
Old 11-10-2009, 05:24 PM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
It does work Qt3 style.
 
Old 11-10-2009, 05:26 PM   #14
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
Quote:
Originally Posted by nadroj View Post
I dont know anything about Qt, but use these instead of the headers you have (which, as the compiler says, dont exist)
Code:
#include <qapplication.h>
#include <qpushbutton.h>
So this is the correct way?
 
Old 11-10-2009, 07:24 PM   #15
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Yes. At least for Qt3, as far as I know.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to compile qt project for i486 using i686 mksc Programming 2 05-18-2009 10:29 AM
Can I compile / build GnomeBasic project. Burgos Programming 1 04-20-2005 08:19 AM
Thanks for helping me to compile my project... Musikolo Linux - Software 11 07-29-2003 11:07 AM
idea for a project: compile manager qanopus General 6 04-30-2003 12:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration