LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-11-2004, 02:19 PM   #1
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Rep: Reputation: 30
qt help compiling


hi

i am new to qt

i tried running a hello world source off of a tutorial i found

here is the source:

#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();
}

then i did:

#qmake -project
#qmake
#make

and i get a whole thing of errors:

helloworld.o(.text+0x1d): In function `main':
: undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
helloworld.o(.text+0x30): In function `main':
: undefined reference to `QString::QString[in-charge](char const*)'
helloworld.o(.text+0x44): In function `main':
: undefined reference to `QPushButton::QPushButton[in-charge](QString const&, QWidget*, char const*)'
helloworld.o(.text+0x62): In function `main':
: undefined reference to `QString::shared_null'
helloworld.o(.text+0x6d): In function `main':
: undefined reference to `QStringData::deleteSelf()'
helloworld.o(.text+0x87): In function `main':
: undefined reference to `QPushButton::resize(int, int)'
helloworld.o(.text+0x90): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
helloworld.o(.text+0x98): In function `main':
: undefined reference to `QWidget::show()'
helloworld.o(.text+0xa0): In function `main':
: undefined reference to `QApplication::exec()'
helloworld.o(.text+0xab): In function `main':
: undefined reference to `QPushButton::~QPushButton [in-charge]()'
helloworld.o(.text+0xb3): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
helloworld.o(.text+0xe9): In function `main':
: undefined reference to `QString::shared_null'
helloworld.o(.text+0xf4): In function `main':
: undefined reference to `QStringData::deleteSelf()'
helloworld.o(.text+0x107): In function `main':
: undefined reference to `QPushButton::~QPushButton [in-charge]()'
helloworld.o(.text+0x117): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
collect2: ld returned 1 exit status
make: *** [qt] Error 1


any suggestions?

thanks
 
Old 06-11-2004, 03:22 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Could you please paste the compilation output (the command you see after you type 'make'), before errors?
 
Old 06-11-2004, 04:00 PM   #3
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
oh sorry

g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/default -I. -I. -I/usr/lib/qt-3.2.1/include -o helloworld.o helloworld.cpp
g++ -o qt helloworld.o -L/usr/X11R6/lib -lXext -lX11 -lm

there you go
 
Old 06-11-2004, 04:10 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
Originally posted by Longinus
g++ -o qt helloworld.o -L/usr/X11R6/lib -lXext -lX11 -lm -lqt
You can also try -lqt-mt if the above doesn't work.
 
Old 06-11-2004, 04:17 PM   #5
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
meh, i tried both but neither worked

the tutorial said all i had to do was:
#qmake -project
#qmake
#make

and then i could just run the binary

any suggestions?
thanks
 
Old 06-11-2004, 04:40 PM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
try to add more #include
#include <qwidget.h>
#include <qpushbutton.h>
#include <qapplication.h>
(and put #include <qapplication.h> in last)
 
Old 06-11-2004, 05:31 PM   #7
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
keefaz it didnt work
hrmm... i tried something new:

#include </usr/lib/qt-3.2.1/include/qwidget.h>
#include </usr/lib/qt-3.2.1/include/qpushbutton.h>
#include </usr/lib/qt-3.2.1/include/qapplication.h>

i typed out the path toe the headers and i get something new:

g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o helloworld.o helloworld.
cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qwidget.o /usr/lib/q
t-3.2.1/include/moc_qwidget.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qpushbutton.o /usr/l
ib/qt-3.2.1/include/moc_qpushbutton.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qapplication.o /usr/
lib/qt-3.2.1/include/moc_qapplication.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qobject.o /usr/lib/q
t-3.2.1/include/moc_qobject.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qbutton.o /usr/lib/q
t-3.2.1/include/moc_qbutton.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qdesktopwidget.o /us
r/lib/qt-3.2.1/include/moc_qdesktopwidget.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qtranslator.o /usr/l
ib/qt-3.2.1/include/moc_qtranslator.cpp
g++ -o qt helloworld.o moc_qwidget.o moc_qpushbutton.o moc_qapplicati
on.o moc_qobject.o moc_qbutton.o moc_qdesktopwidget.o moc_qtranslator.
o -L/usr/X11R6/lib -lXext -lX11 -lm
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o helloworld.o helloworld.
cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qwidget.o /usr/lib/q
t-3.2.1/include/moc_qwidget.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qpushbutton.o /usr/l
ib/qt-3.2.1/include/moc_qpushbutton.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qapplication.o /usr/
lib/qt-3.2.1/include/moc_qapplication.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qobject.o /usr/lib/q
t-3.2.1/include/moc_qobject.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qbutton.o /usr/lib/q
t-3.2.1/include/moc_qbutton.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qdesktopwidget.o /us
r/lib/qt-3.2.1/include/moc_qdesktopwidget.cpp
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt-3.2.1/mkspecs/d
efault -I. -I. -I/usr/lib/qt-3.2.1/include -o moc_qtranslator.o /usr/l
ib/qt-3.2.1/include/moc_qtranslator.cpp
g++ -o qt helloworld.o moc_qwidget.o moc_qpushbutton.o moc_qapplicati
on.o moc_qobject.o moc_qbutton.o moc_qdesktopwidget.o moc_qtranslator.
o -L/usr/X11R6/lib -lXext -lX11 -lm


but i still get the error

and also some strange files appear in the directory i compiled helloworld in:

moc_qapplication.o
moc_qbutton.o
moc_qdesktopwidget.o
moc_qobject.o
moc_qpushbutton.o
moc_qtranslator.o
moc_qwidget.o

any suggestions?
 
Old 06-12-2004, 12:57 AM   #8
Longinus
Member
 
Registered: Sep 2003
Distribution: Redhat 9.0 && Slackware 9.1
Posts: 420

Original Poster
Rep: Reputation: 30
hrmm i got it working now

i renamed it as main.cpp and it works now

lol

oh well thanks for the suggestions
 
  


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
Compiling narcussist Fedora 6 01-18-2006 12:50 PM
compiling z9_87 Linux - Software 4 12-23-2004 05:29 PM
Various Compiling Errors (GCC compiling Openal, GUIlib, xmms-wma) gregorya Linux - Software 2 08-27-2004 05:03 AM
Compiling in ACPI support on Compaq 2135CA (system crashes while compiling) Dag Linux - Laptop and Netbook 20 07-30-2004 07:56 PM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM

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

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