首页| 论坛| 消息

标题:【提问】helloworld编译不成功,什么原因
作者:magicoy
日期:2005-08-28 23:01
内容:

我真的要疯了.................
代码如下................我编译了N次都不成功.我再用文本编译器写成cpp.再qmake -project再qmake再make
每次都不行.我又重新安装QT 3.3.4还是不行...............都是一样的效果.如果大家不帮我.我活不下去了.....................
---------------------------------------------------------------------------------------------代码如下---------------------
#include
#include

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();
}
--------------------------------------------------------------------------------------------make时候提示----如下----
# ls
MagicLinuxmiimagesqt
# cd qt
# qmake -project
# qmake
# make
g++ -c -pipe -Wall -W -O2 -g -pipe -D_FORTIFY_SOURCE=2 -m32 -march=i686 -mcpu=i686 -mtune=i686 -DQT_NO_DEBUG-I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o qtt.o qtt.cpp
g++-o qt qtt.o -L/usr/X11R6/lib -lXext -lX11 -lm
qtt.o(.text+0x33): In function `main':
/root/Desktop/qt/qtt.cpp:7: undefined reference to `QApplication::QApplication(int&, char**)'
qtt.o(.text+0x44):/root/Desktop/qt/qtt.cpp:9: undefined reference to `QString::QString(char const*)'
qtt.o(.text+0x62):/root/Desktop/qt/qtt.cpp:9: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*, char const*)'
qtt.o(.text+0x77): In function `main':
/usr/lib/qt-3.3/include/qstring.h:847: undefined reference to `QString::shared_null'
qtt.o(.text+0x81):/usr/lib/qt-3.3/include/qstring.h:848: undefined reference to `QStringData::deleteSelf()'
qtt.o(.text+0xa6): In function `main':
/root/Desktop/qt/qtt.cpp:10: undefined reference to `QPushButton::resize(int, int ..


#1 [running 08-29 00:19]
你看看文档 应该QPushButton的定义不对
#2 [giscn 08-29 01:14]
g++ -c -pipe -Wall -W -O2 -g -pipe -D_FORTIFY_SOURCE=2 -m32 -march=i686 -mcpu=i686 -mtune=i686 -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o qtt.o qtt.cpp
g++ -o qt qtt.o -L/usr/X11R6/lib -lXext -lX11 -lm
这里有问题,没有连接到 -lqt-mt,所以检查你的kdev配置,除了inlcude目录,还得注意lib目录是否配置好了
#3 [magicoy 08-29 02:22]
楼上.你可以问Xchinux.
我做个最简单的QT程序hello world搞了半个月了............
还没搞好.............我想了各种办法都不行.你一定要帮我啊.
我QQ:290078300
我希望QQ里能说清楚点.........................谢谢了
#4 [giscn 08-29 05:23]
下面是引用magicoy于2005-08-29 02:22发表的:
楼上.你可以问Xchinux.
我做个最简单的QT程序hello world搞了半个月了............
还没搞好.............我想了各种办法都不行.你一定要帮我啊.
我QQ:290078300
我希望QQ里能说清楚点.........................谢谢了
晕,又不是我的问题,我问Xchinux干什么?
#5 [XChinux 08-29 08:24]
汗啊。。看看那些出错信息,就一个一个的解决问题了。
在VC、TC等环境里,也给出出错信息的,那里能看,这里也能看,只不过是在控制台的。上面已经给出来出错的行号,和原因:
g++ -c -pipe -Wall -W -O2 -g -pipe -D_FORTIFY_SOURCE=2 -m32 -march=i686 -mcpu=i686 -mtune=i686 -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o qtt.o qtt.cpp
g++ -o qt qtt.o -L/usr/X11R6/lib -lXext -lX11 -lm
qtt.o(.text+0x33): In function `main':
/root/Desktop/qt/qtt.cpp:7: undefined reference to `QApplication::QApplication(int&, char**)'
qtt.o(.text+0x44):/root/Desktop/qt/qtt.cpp:9: undefined reference to `QString::QString(char const*)'
qtt.o(.text+0x62):/root/Desktop/qt/qtt.cpp:9: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*, char const*)'
qtt.o(.text+0x77): In function `main':
/usr/lib/qt-3.3/include/qstring.h:847: undefined reference to `QString::shared_null'
qtt.o(.text+0x81):/usr/lib/qt-3.3/include/qstring.h:848: undefined reference to `QStringData::deleteSelf()'
qtt.o(.text+0xa6): In function `main':
/root/Desktop/qt/qtt.cpp:10: undefined reference to `QPushButton::resize(int, int)'
qtt.o(.text+0xb2):/root/Desktop/qt/qtt.cpp:12: undefined reference to `QApplication::setMainWidget(QWidget*)'
qtt.o(.text+0xba):/root/Desktop/qt/qtt.cpp:13: undefined reference to `QWidget::show()'
qtt.o(.text+0xc2):/root/Desktop/qt/qtt.cpp:14: undefined reference to `QApplication::exec()'
qtt.o(.text+0xcc):/root/Desktop/qt/qtt.cpp:14: undefined reference to `QPushButton::~QPushButton()'
qtt.o(.text+0xd4):/root/Desktop/qt/qtt.cpp:14: undefined reference to `QApplication::~QApplication()'
qtt.o(.text+0xfa): In function `main':
/usr/lib/qt-3.3/include/qstring.h:847: undefined reference to `QString::shared_null'
qtt.o(.text+0x104):/usr/lib/qt-3.3/include/qstring.h:848: undefined reference to `QStringData::deleteSelf()'
qtt.o(.text+0x116): In function `main':
/root/Deskt ..

<< 1 2 3 >> (1/3)

回复 发表
主题 版块