LinuxQuestions.org
Review your favorite Linux distribution.
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 07-01-2004, 12:57 PM   #1
vanhelsing
Member
 
Registered: May 2004
Posts: 130

Rep: Reputation: 15
How to compile c++ and using qt


This is all work and my problem----->

[root@localhost mycpp]# ls
hello.cpp
[root@localhost mycpp]# grep -qa|grep qt
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
[root@localhost mycpp]# rpm -qa|grep qt
qtcups-2.0-15
qt-3.1.1-6
[root@localhost mycpp]# cat hello.cpp
#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();
}

[root@localhost mycpp]# g++ hello.cpp
hello.cpp:1:26: qapplication.h: No such file or directory
hello.cpp:2:25: qpushbutton.h: No such file or directory
hello.cpp: In function `int main(int, char**)':
hello.cpp:6: `QApplication' undeclared (first use this function)
hello.cpp:6: (Each undeclared identifier is reported only once for each
function it appears in.)
hello.cpp:6: parse error before `(' token
hello.cpp:7: `QPushButton' undeclared (first use this function)
hello.cpp:8: `hello' undeclared (first use this function)
hello.cpp:9: `a' undeclared (first use this function)
[root@localhost mycpp]#

Did I make something wrong?
How to compile hello.cpp and to execute it?

 
Old 07-01-2004, 01:03 PM   #2
vanhelsing
Member
 
Registered: May 2004
Posts: 130

Original Poster
Rep: Reputation: 15
and pls, recommend me easy way to install "qmake" and to use it
 
Old 07-01-2004, 05:01 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You need to install qt-devel package. Then, if you compile it using
g++ -o hello hello.cpp -lqt
it should work (-lqt because you need to link with the Qt library).
 
Old 07-01-2004, 10:35 PM   #4
rshinoy
LQ Newbie
 
Registered: May 2004
Posts: 10

Rep: Reputation: 0
Problem seems to be with -I option being ommitted

provide both -I and -L option for this

g++ -I/usr/include/ -o qt_test qt_test.cpp -L/usr/lib/ -lqt

here /usr is taken as default installation directory which in your case is different .
 
Old 07-01-2004, 10:59 PM   #5
rshinoy
LQ Newbie
 
Registered: May 2004
Posts: 10

Rep: Reputation: 0
try this otption

g++ -I/usr/lib/qt-3.1.1-6/include/ -o qt_test qt_test.cpp -L/usr/lib/qt-3.1.1-6/lib/ -lqt
 
  


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
How do I compile? icecream33 Programming 3 12-20-2017 11:49 AM
compile 2.6.13 jupiter3437 Linux - Software 3 09-09-2005 04:09 PM
ntop compile/post-compile problem? tjb Linux - Software 3 12-28-2004 04:22 PM
Cannot compile c davidtsl Programming 8 12-13-2004 01:36 AM
Compile help Twiggy794 Linux - Software 1 12-03-2003 01:53 AM

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

All times are GMT -5. The time now is 06:05 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