LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-28-2009, 06:25 AM   #1
mashern
LQ Newbie
 
Registered: Jan 2009
Location: South Africa
Distribution: Fedora
Posts: 5

Rep: Reputation: 0
Qt headers not found (g++)


PLEASE HELP!!!I have a problem compiling qt applications, the qt headers file not found but when i check manually found in their dir.
here is the code i tried.

Fedora 10 i686 machine
/***********************
#include <QApplication>
#include <QLabel>


int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}
**********************************************
output
[Ernest@pulse Hello]$ make
g++ -o Hello hello.o -L/usr/lib/qt-3.3/lib -lqt-mt -lXext -lX11 -lm
hello.o: In function `main':
/home/Ernest/Practice/Hello/hello.cpp:6: undefined reference to `QApplication::QApplication(int&, char**, int)'
hello.o: In function `QString':
/usr/include/QtCore/qstring.h:385: undefined reference to `QString::fromAscii_helper(char const*, int)'
hello.o: In function `main':
/home/Ernest/Practice/Hello/hello.cpp:7: undefined reference to `QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>)'
hello.o: In function `~QString':
/usr/include/QtCore/qstring.h:825: undefined reference to `QString::free(QString:ata*)'
/usr/include/QtCore/qstring.h:825: undefined reference to `QString::free(QString:ata*)'
collect2: ld returned 1 exit status
make: *** [Hello] Error 1
 
Old 01-28-2009, 07:10 AM   #2
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,076
Blog Entries: 52

Rep: Reputation: Disabled
Some distros split their libraries into runtime and development parts. Not sure if that's the case here, but see if you've got qt libs with the -dev suffix.
 
Old 01-28-2009, 08:16 AM   #3
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
The errors you're getting are linker errors. It isn't that the headers can't be found, it's (presumably) that the required shared object files can't be found. Did you write the makefile yourself? I believe Qt has its own makefile generator (or something like that anyway).
 
Old 01-28-2009, 09:55 AM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 248

Rep: Reputation: 50
Quote:
Originally Posted by Nylex View Post
I believe Qt has its own makefile generator (or something like that anyway).
Nylex is correct.

In the directory where your code resides you need to run:
Code:
qmake -project
qmake
make
 
Old 01-29-2009, 04:20 AM   #5
mashern
LQ Newbie
 
Registered: Jan 2009
Location: South Africa
Distribution: Fedora
Posts: 5

Original Poster
Rep: Reputation: 0
I generated the makefile with qmake following all procedures mentioned in the Qt tutorial
 
Old 01-29-2009, 10:26 AM   #6
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 248

Rep: Reputation: 50
Have you installed the qt development package? On Debian it is called qt3-dev-tools, don't know about Fedora.
Did you set the QTDIR environment variable?
 
Old 01-30-2009, 03:49 AM   #7
mashern
LQ Newbie
 
Registered: Jan 2009
Location: South Africa
Distribution: Fedora
Posts: 5

Original Poster
Rep: Reputation: 0
On fedora, qt-devel is included by default. I have downloaded additional qt rpm's but still doesn't work. I am not sure about setting QTDIR environment variable.
 
Old 01-30-2009, 09:40 AM   #8
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 248

Rep: Reputation: 50
The installation instructions are kind of buried in the docs: link

Trolltech, now Qt Software and part of Nokia, is going to release QT 4.5 under the LGPL in March so you are are somewhat behind the curve using v3.3.
 
Old 01-31-2009, 12:09 AM   #9
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 248

Rep: Reputation: 50
Looking more closely at your code it appears the tutorial you are following is for QT 4.0 and above and you are trying to compile it under 3.3.

For it to compile and run you need to make the following changes:
In QT 3.3 the header files are as follows:
Code:
#include <qapplication.h>
#include <qlabel.h>
And change your QLabel line to:
Code:
QLabel *label = new QLabel("Hello Qt!", 0 );
I'm currently using QT 4.4.0 so the above is mostly from memory and briefly perusing the 3.3 docs. Your code compiles and runs fine under 4.4.0

Last edited by norobro; 01-31-2009 at 12:16 AM.
 
Old 01-31-2009, 05:37 AM   #10
mashern
LQ Newbie
 
Registered: Jan 2009
Location: South Africa
Distribution: Fedora
Posts: 5

Original Poster
Rep: Reputation: 0
thanks, i managed to get it right.
 
  


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
OpenSSL Crypto headers not found. jmoulinier Linux - Software 17 09-16-2011 07:19 PM
Qt headers and libraries not found c-- Ubuntu 12 03-03-2009 08:16 PM
No kernel headers found. What? colly Linux - General 1 02-21-2004 11:01 AM
QT-1.3 (headers and libraries) not found. p_reah Linux - Software 2 04-17-2003 08:11 PM
KDE headers not found...check your installation jayakrishnan Linux - General 14 11-19-2002 08:46 AM


All times are GMT -5. The time now is 01:04 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration