免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4629 | 回复: 9
打印 上一主题 下一主题

Qt hello world [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-12-06 10:20 |只看该作者 |倒序浏览
有个简单的程序如下,
#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();
}
gcc -c hello.cpp 成功!可是link时有错,请高手指点。

ld -o hello -L /usr/local/qt hello.o                           
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048074
hello.o: In function `main':
hello.o(.text+0x23): undefined reference to `QApplication:Application(int&, char**)'
hello.o(.text+0x3b): undefined reference to `QString:String(char const*)'
hello.o(.text+0x51): undefined reference to `QPushButton:PushButton(QString const&, QWidget*, char const*)'
hello.o(.text+0xa4): undefined reference to `QPushButton::resize(int, int)'
hello.o(.text+0xba): undefined reference to `QApplication::setMainWidget(QWidget*)'
hello.o(.text+0xcc): undefined reference to `QWidget::show()'
hello.o(.text+0xdb): undefined reference to `QApplication::exec()'
hello.o(.text+0xf3): undefined reference to `QPushButton::~QPushButton()'
hello.o(.text+0x102): undefined reference to `QApplication::~QApplication()'
hello.o(.text+0x12e): undefined reference to `QPushButton::~QPushButton()'
hello.o(.text+0x151): undefined reference to `QApplication::~QApplication()'
hello.o(.text+0x16: undefined reference to `_Unwind_Resume'
hello.o: In function `QString::~QString()':
hello.o(.gnu.linkonce.t._ZN7QStringD1Ev+0x21): undefined reference to `QString::shared_null'
hello.o(.gnu.linkonce.t._ZN7QStringD1Ev+0x30): undefined reference to `QStringData::deleteSelf()'
hello.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'

论坛徽章:
0
2 [报告]
发表于 2004-12-06 10:34 |只看该作者

Qt hello world

你这个helloworld程序是从哪里抄来的,就到哪里仔细看看QT程序的编译方法。
由于它的类里边有一些诸如slot之类的东西,不能这样编译的。
www.qiliang.net是个好地方

论坛徽章:
0
3 [报告]
发表于 2004-12-06 10:45 |只看该作者

Qt hello world

你没有连接qt的库
缺省在/usr/lib/qt.....

论坛徽章:
0
4 [报告]
发表于 2004-12-06 10:45 |只看该作者

Qt hello world

我又试了用qmake -project, qmake, make, 还是有一样的错误!!

论坛徽章:
0
5 [报告]
发表于 2004-12-06 10:58 |只看该作者

Qt hello world

我也刚学QT不知道我说的对不
qmake -o Makefile hello.pro
make

论坛徽章:
0
6 [报告]
发表于 2004-12-06 11:31 |只看该作者

Qt hello world

qmake -o Makefile hello.pro
make

没错,
如果还是连接不上,就在Makefile里直接加上类似Libqt.so.3...好了。

论坛徽章:
0
7 [报告]
发表于 2004-12-06 12:35 |只看该作者

Qt hello world

在Makefile里加了,也不行,还是有同样的错。在make时,提示下面这行。

g++  -o qt main.o    -L/usr/X11R6/lib -lXext -lX11 -lm -L/usr/local/qt/lib/libqt.so.3.3.3

或者我把-L/usr/local/qt/lib/libqt.so.3.3.3 改成-L/usr/local/qt/lib,也是不行的。

论坛徽章:
0
8 [报告]
发表于 2004-12-06 14:28 |只看该作者

Qt hello world

我把cpp文件放到一个空目录里,再重新做一次,结果,这次就成了,真怪!

论坛徽章:
0
9 [报告]
发表于 2010-09-08 13:15 |只看该作者
LIBS          = $(SUBLIBS)   -lQtGui -lQtCore -lpthread

论坛徽章:
0
10 [报告]
发表于 2010-09-08 13:31 |只看该作者
我一开始装的QTSDK,看了里面编译时候的输出就啥都明白了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP