Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-23-2004, 10:59 PM   #1
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206

Rep: Reputation: 30
simple question about qt and compiling

I am a humble beginner on qt.
Recently, I follow the tutorail,
copy the code
#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 );;
return a.exec();
in a *.txt and save it as main.cpp
copy the file main.cpp to /usr/bin where the executable file qmake
then qmake -project
but no *.pro file in the folder /usr/bin.
thank you.

Last edited by Xiangbuilder; 07-23-2004 at 11:23 PM.
Old 07-24-2004, 02:03 AM   #2
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
You don't want to copy the main.cpp file to /usr/bin, that's where the finished program should go. Just save the main.cpp file to your home directory or something...then, in the directory you saved main.cpp in, type 'qmake -project && qmake'.
Old 07-24-2004, 08:05 AM   #3
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206

Original Poster
Rep: Reputation: 30
thank you, the file has come up.
but a new problem appear when I try to make

[root@localhost qt]# qmake -project
[root@localhost qt]# qmake
[root@localhost qt]# ls
main.cpp Makefile
[root@localhost qt]# make
g++ -c -pipe -Wall -W -O2 -g -pipe -march=i386 -mcpu=i686 -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I. -I/usr/lib/qt-3.1/include -o main.o main.cpp
g++ -o qt main.o -L/usr/X11R6/lib -lXext -lX11 -lm
main.o(.text+0x2c): In function `main':
/hda07_freedom/creation/c++_fb/qt/main.cpp:14: undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
main.o(.text+0x3d):/hda07_freedom/creation/c++_fb/qt/main.cpp:16: undefined reference to `QString::QString[in-charge](char const*)'
main.o(.text+0x59):/hda07_freedom/creation/c++_fb/qt/main.cpp:16: undefined reference to `QPushButton::QPushButton[in-charge](QString const&, QWidget*, char const*)'
main.o(.text+0x6e): In function `main':
/usr/lib/qt-3.1/include/qstring.h:770: undefined reference to `QString::shared_null'
main.o(.text+0x78):/usr/lib/qt-3.1/include/qstring.h:771: undefined reference to `QStringData::deleteSelf()'
main.o(.text+0x96): In function `main':
/hda07_freedom/creation/c++_fb/qt/main.cpp:17: undefined reference to `QPushButton::resize(int, int)'
main.o(.text+0xa2):/hda07_freedom/creation/c++_fb/qt/main.cpp:19: undefined reference to `QApplication::setMainWidget(QWidget*)'
main.o(.text+0xaa):/hda07_freedom/creation/c++_fb/qt/main.cpp:20: undefined reference to `QWidget::show()'
main.o(.text+0xb2):/hda07_freedom/creation/c++_fb/qt/main.cpp:21: undefined reference to `QApplication::exec()'
main.o(.text+0xbc):/hda07_freedom/creation/c++_fb/qt/main.cpp:21: undefined reference to `QPushButton::~QPushButton [in-charge]()'
main.o(.text+0xc4):/hda07_freedom/creation/c++_fb/qt/main.cpp:21: undefined reference to `QApplication::~QApplication [in-charge]()'
main.o(.gnu.linkonce.r._ZTV6QGList+0xc): In function `main':
/usr/lib/qt-3.1/include/qglist.h:147: undefined reference to `QGList::clear()'
main.o(.gnu.linkonce.r._ZTV6QGList+0x10):/usr/lib/qt-3.1/include/qglist.h:147: undefined reference to `QGList::~QGList [in-charge]()'
main.o(.gnu.linkonce.r._ZTV6QGList+0x14): In function `main':
/hda07_freedom/creation/c++_fb/qt/main.cpp:16: undefined reference to `QGList::~QGList [in-charge deleting]()'
main.o(.gnu.linkonce.r._ZTV6QGList+0x18):/hda07_freedom/creation/c++_fb/qt/main.cpp:14: undefined reference to `QPtrCollection::newItem(void*)'
main.o(.gnu.linkonce.r._ZTV6QGList+0x20):/hda07_freedom/creation/c++_fb/qt/main.cpp:14: undefined reference to `QGList::compareItems(void*, void*)'
main.o(.gnu.linkonce.r._ZTV6QGList+0x24):/hda07_freedom/creation/c++_fb/qt/main.cpp:14: undefined reference to `QGList::read(QDataStream&, void*&)'
main.o(.gnu.linkonce.r._ZTV6QGList+0x28):/hda07_freedom/creation/c++_fb/qt/main.cpp:14: undefined reference to `QGList::write(QDataStream&, void*) const'
main.o(.gnu.linkonce.r._ZTI6QGList+0x8):/hda07_freedom/creation/c++_fb/qt/main.cpp:16: undefined reference to `typeinfo for QPtrCollection'
collect2: ld returned 1 exit status
make: *** [qt] Error 1

what is wrong?
thank you.
Old 07-24-2004, 10:58 PM   #4
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206

Original Poster
Rep: Reputation: 30
I notice that there is no lqt or lqt-mt in the line
g++ -o qt main.o -L/usr/X11R6/lib -lXext -lX11 -lm

so I don't use make command, I use g++ directly like this:
g++ -o qt main.o -L/usr/X11R6/lib -lqt -lXext -lX11 -lm

them it is soloved.
thank you.


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
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
Kernel Compiling Simple Question Obscure Slackware 5 08-19-2003 01:19 PM
Simple compiling question??? cameronknives Linux - General 5 02-10-2002 10:58 AM
simple question seeking simple answer enzo250gto Linux - Newbie 1 10-27-2001 04:08 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration