LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 12-23-2006, 07:58 AM   #1
joakim12
Member
 
Registered: Nov 2003
Location: Estonia
Distribution: Ubuntu 18.04
Posts: 82

Rep: Reputation: 15
noob having problems to compile first Qt "hello world" application


I'm trying to compile the next Qt code:

Code:
#include <qapplication.h>
#include <qpushbutton.h>

int main( int argc, char **argv )
{
    QApplication a( argc, argv );
    QPushButton hello( "Hello world!", 0 );
    hello.resize( 100, 30 );
    a.setMainWidget( &hello );
    hello.show();
    return a.exec();
}
But first I had this problem:

Code:
hello.cpp:1:125: error: qapplication.h: No such file or directory
hello.cpp:2:125: error: qpushbutton.h: No such file or directory
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:6: error: ‘QApplication’ was not declared in this scope
hello.cpp:6: error: expected `;' before ‘a’
hello.cpp:7: error: ‘QPushButton’ was not declared in this scope
hello.cpp:7: error: expected `;' before ‘hello’
hello.cpp:8: error: ‘hello’ was not declared in this scope
hello.cpp:9: error: ‘a’ was not declared in this scope
Then I installed libqt4-dev with apt-get and now I'm having the next problem

Code:
joakim@leho:~/qt$ g++ -Wall -I/usr/include/qt4/Qt -L/usr/lib hello.cpp -l hello -lqt
In file included from hello.cpp:1:
/usr/include/qt4/Qt/qapplication.h:27:37: error: QtCore/qcoreapplication.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:28:31: error: QtGui/qwindowdefs.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:29:27: error: QtCore/qpoint.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:30:26: error: QtCore/qsize.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:31:27: error: QtGui/qcursor.h: No such file or directory
In file included from hello.cpp:2:
/usr/include/qt4/Qt/qpushbutton.h:27:35: error: QtGui/qabstractbutton.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:44: error: ‘QT_BEGIN_HEADER’ does not name a type
/usr/include/qt4/Qt/qapplication.h:64: error: invalid function declaration
/usr/include/qt4/Qt/qapplication.h:336: error: ‘QT_END_HEADER’ does not name a type
/usr/include/qt4/Qt/qpushbutton.h:36: error: invalid function declaration
hello.cpp:4: error: expected constructor, destructor, or type conversion before ‘int’
Are the Qt library headers installed wrongly or what is the problem?

Code:
joakim@leho:~/qt$ find /usr/ -iname qcoreapplication.h
/usr/include/qt4/Qt/qcoreapplication.h
/usr/include/qt4/QtCore/qcoreapplication.h
Thank you for your time and help.
 
Old 12-23-2006, 02:14 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Try #include <QApplication> etc.
Have you tried compiling Qt examples to make sure Qt is correctly installed?
 
Old 12-23-2006, 06:27 PM   #3
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 25, 26, RHL 5.2
Posts: 560

Rep: Reputation: 56
Have you tried using qmake in the directory with the hello.cpp? Try this...

1) qmake -project
2) qmake
3) make
4) ./hello

Bill
 
Old 06-02-2010, 11:26 PM   #4
nirucool89
LQ Newbie
 
Registered: Jun 2010
Posts: 3

Rep: Reputation: 0
sir,hav made the following code:

#include <QApplication>
#include <QPushButton>

int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );
a.setMainWidget( &hello );
hello.show();
return a.exec();
}

n got the same errors as my frnd joakim12 is getting...QApplication :no such file or directory etc..etc..
sir help me..how to correct these errors..i hav to make my project using Qt..waiting 4 ur reply...ASAP
 
Old 06-03-2010, 08:39 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
1. This thread is 4 years old

2. I hardly understand a word of what you said.
 
  


Reply



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
Trying to Compile "hello world" Kernel Module (please help!) antdengineer Programming 9 12-04-2010 04:07 AM
"Hello, World!" compiling problems BurningBreeze Programming 6 01-16-2006 04:04 PM
Can't compile an application named "kover" OggVorbis Mandriva 4 05-13-2004 01:49 PM
Kernel compile problems with "mm" Hex29A Debian 2 12-31-2003 05:33 AM

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

All times are GMT -5. The time now is 07:55 PM.

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