simple question about qt and compiling
I am a humble beginner on qt.
Recently, I follow the tutorail, http://doc.trolltech.com/3.3/tutorial1-01.html 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 ); hello.show(); 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 lived. then qmake -project but no *.pro file in the folder /usr/bin. why? thank you. my email:liouxiangbiao@yahoo.com.cn |
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'.
|
thank you, the file qt.pro 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 qt.pro [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. |
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. http://www.fbuilder.com/tem/qt_a.png thank you. |
All times are GMT -5. The time now is 08:19 PM. |