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 11-15-2006, 07:06 AM   #1
grezly
Member
 
Registered: May 2006
Distribution: Slackware
Posts: 46

Rep: Reputation: 15
qt compile error


I'am trying to compile a qt program.

Code:
dave@flaptop:~/qt$ cat hello.cpp
#include <qapplication.h>
#include <qlabel.h>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Linux is wonderful", 0);
app.setMainWidget(label);
label->show();
return app.exec();
}
Then i'll do the following:

Code:
dave@flaptop:~/qt$ qmake -project
dave@flaptop:~/qt$ qmake qt.pro
If i'll compile it the compiler says:
Code:
dave@flaptop:~/qt$ make
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG  -I/usr/lib/qt/mkspecs/default -I. -I. -I/usr/lib/qt/include -o hello.o hello.cpp
hello.cpp:11:2: warning: no newline at end of file
g++  -o qt hello.o    -L/usr/X11R6/lib -lXext -lX11 -lm
hello.o(.text+0x1c): In function `main':
: undefined reference to `QApplication::QApplication(int&, char**)'
hello.o(.text+0x2c): In function `main':
: undefined reference to `QString::QString(char const*)'
hello.o(.text+0x4c): In function `main':
: undefined reference to `QLabel::QLabel(QString const&, QWidget*, char const*, unsigned int)'
hello.o(.text+0x61): In function `main':
: undefined reference to `QString::shared_null'
hello.o(.text+0x6c): In function `main':
: undefined reference to `QStringData::deleteSelf()'
hello.o(.text+0x79): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
hello.o(.text+0x8c): In function `main':
: undefined reference to `QApplication::exec()'
hello.o(.text+0x97): In function `main':
: undefined reference to `QApplication::~QApplication()'
hello.o(.text+0xc5): In function `main':
: undefined reference to `QApplication::~QApplication()'
hello.o(.text+0x10c): In function `main':
: undefined reference to `QString::shared_null'
hello.o(.text+0x117): In function `main':
: undefined reference to `QStringData::deleteSelf()'
hello.o(.gnu.linkonce.r._ZTV6QGList+0xc): undefined reference to `QGList::clear()'
hello.o(.gnu.linkonce.r._ZTV6QGList+0x10): undefined reference to `QGList::~QGList()'
hello.o(.gnu.linkonce.r._ZTV6QGList+0x14): undefined reference to `QGList::~QGList()'
hello.o(.gnu.linkonce.r._ZTV6QGList+0x18): undefined reference to `QPtrCollection::newItem(void*)'
hello.o(.gnu.linkonce.r._ZTV6QGList+0x20): undefined reference to `QGList::compareItems(void*, void*)'
hello.o(.gnu.linkonce.r._ZTV6QGList+0x24): undefined reference to `QGList::read(QDataStream&, void*&)'
hello.o(.gnu.linkonce.r._ZTV6QGList+0x28): undefined reference to `QGList::write(QDataStream&, void*) const'
hello.o(.gnu.linkonce.r._ZTI6QGList+0x8): undefined reference to `typeinfo for QPtrCollection'
collect2: ld returned 1 exit status
make: *** [qt] Error 1
dave@flaptop:~/qt$
libqt is available on this system:

Code:
dave@flaptop:~/qt$ locate libqt
/opt/kde/lib/libqtjava.so.1.0.0
/opt/kde/lib/libqtjava.la
/opt/kde/lib/libqtjava.so
/opt/kde/lib/libqtjavasupport.so.1.0.0
/opt/kde/lib/libqtmcop.la
/opt/kde/lib/libqtmcop.so
/opt/kde/lib/libqtjavasupport.la
/opt/kde/lib/libqtjavasupport.so
/opt/kde/lib/libqtmcop.so.1.0.0
/opt/kde/lib/libqtopiakonnector.la
/opt/kde/lib/libqtopiakonnector.so
/opt/kde/lib/libqtjava.so.1
/opt/kde/lib/libqtjavasupport.so.1
/opt/kde/lib/libqtmcop.so.1
/opt/google-earth/libqt-mt.so.3
/usr/lib/qt-3.3.7/lib/libqt-mt.so.3
/usr/lib/qt-3.3.7/lib/libqt-mt.prl
/usr/lib/qt-3.3.7/lib/libqt-mt.la
/usr/lib/qt-3.3.7/lib/libqt-mt.so
/usr/lib/qt-3.3.7/lib/libqt-mt.so.3.3.7
/usr/lib/qt-3.3.7/lib/libqt-mt.so.3.3
And i'll also copied the libqt files to /usr/X11R6/lib.

Last edited by grezly; 11-15-2006 at 07:07 AM.
 
Old 11-15-2006, 10:23 AM   #2
rstewart
Member
 
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Hi,

I may be wrong, but I don't see where you specify the qt library in your link command? Shouldn't you need to do something like this: "g++ -o qt hello.o -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm"

I hope that this helps. I'm playing with Qt on a windows platform right now and as soon as I have created a sample application I plan on "porting" it to Linux to see how easy/hard that process is.

Have fun!
 
Old 11-15-2006, 11:46 AM   #3
grezly
Member
 
Registered: May 2006
Distribution: Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Code:
g++  -o qt hello.o    -L/usr/X11R6/lib -lXext -lX11 -lm
The makefile does this for me

The '-lqt-mt ' was the problem.
Now it works

Last edited by grezly; 11-15-2006 at 12:16 PM.
 
  


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
Compile madwifi, ... compile error , how can i do. ERBRMN Linux - Networking 3 03-08-2006 07:56 PM
compile error with 2.6.5 jamaas Linux - Newbie 6 04-17-2004 01:11 AM
2.4.2 Compile error Seventh Linux - Newbie 2 02-18-2004 12:20 PM
compile error: #error unknown processor family kmack2001 Linux - Newbie 0 02-14-2004 11:52 AM
Alsa compile error, and a WINE error scheidel21 Linux - Software 1 12-08-2003 08:16 PM

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

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