LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 08-11-2003, 06:55 PM   #1
siphiuel
LQ Newbie
 
Registered: Aug 2003
Posts: 4

Rep: Reputation: 0
Problems when trying to compile cpp files using qt headers


Hello. I have mandrake 9.1. I've tried to use qt assistant to learn gui programming (at least to see what it is). I have done everything exactly as it was written in the tutorial #1 of the qt assistant. But when i try to compile the file HelloWorld.cpp using make or g++ there are lots of errors saying about undefined references. What's wrong? Thanks in advance.

Here are the messages produced:
[blade@localhost qt]$ qmake -project
[blade@localhost qt]$ qmake
[blade@localhost qt]$ make
g++ -o qt qt.o -L/usr/X11R6/lib -lXext -lX11 -lm
qt.o(.text+0x30): In function `main':
: undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
qt.o(.text+0x40): In function `main':
: undefined reference to `QString::QString[in-charge](char const*)'
qt.o(.text+0x62): In function `main':
: undefined reference to `QPushButton::QPushButton[in-charge](QString const&, QWidget*, char const*)'
qt.o(.text+0x7d): In function `main':
: undefined reference to `QString::shared_null'
qt.o(.text+0x87): In function `main':
: undefined reference to `QStringData::deleteSelf()'
qt.o(.text+0xa4): In function `main':
: undefined reference to `QPushButton::resize(int, int)'
qt.o(.text+0xb0): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
qt.o(.text+0xb8): In function `main':
: undefined reference to `QWidget::show()'
qt.o(.text+0xc0): In function `main':
: undefined reference to `QApplication::exec()'
qt.o(.text+0xca): In function `main':
: undefined reference to `QPushButton::~QPushButton [in-charge]()'
qt.o(.text+0xd2): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
qt.o(.text+0xfe): In function `main':
: undefined reference to `QString::shared_null'
qt.o(.text+0x108): In function `main':
: undefined reference to `QStringData::deleteSelf()'
qt.o(.text+0x116): In function `main':
: undefined reference to `QPushButton::~QPushButton [in-charge]()'
qt.o(.text+0x126): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
collect2: ld returned 1 exit status
make: *** [qt] Error 1


Report this pos
 
Old 08-12-2003, 04:41 AM   #2
seidren
Member
 
Registered: May 2003
Distribution: Ubuntu, Windows XP
Posts: 90

Rep: Reputation: 16
judging from the error messages i think you havent included the lines...

#include <qappplication.h>
#include <qpushbutton.h>

Anyway if you are using Qt Designer
you should
1. Create a new project and design the interface
2. Insert a "C++ Main" source file (just the way you inserted the dialog box or main window"
3. qmake -project
4. qmake
5. make
6. run the program

Everything should work fine.
 
Old 08-12-2003, 04:41 AM   #3
seidren
Member
 
Registered: May 2003
Distribution: Ubuntu, Windows XP
Posts: 90

Rep: Reputation: 16
Also check if g++ can reach the library files of Qt

usually qmake takes care of this but this might also be your problem.

append the path of the qt library with -L/<path>

Last edited by seidren; 08-12-2003 at 04:50 AM.
 
  


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 a C++ file (.cpp) with allegro? RHLinuxGUY Programming 5 11-29-2005 02:06 AM
How do I compile a *.cpp Document in linux? njbrain Linux - Software 9 01-29-2004 07:43 PM
compile programs in c and cpp Manjula.S Linux - Software 2 10-15-2003 01:06 AM
Problems when trying to compile cpp files using qt headers siphiuel Linux - Software 2 08-10-2003 07:10 PM
to compile cpp on linux mandrake manpreet Programming 1 04-26-2001 12:45 AM


All times are GMT -5. The time now is 11:29 AM.

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