亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 9185 | 回復: 12
打印 上一主題 下一主題

Qt 編譯hello程序 undefined reference 出錯 求助! [復制鏈接]

論壇徽章:
0
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2010-11-12 11:08 |只看該作者 |倒序瀏覽
hello.cpp程序如下:

#include <qapplication.h>
#include <qlabel.h>

int main(int argc, char **argv)
{
        QApplication app(argc, argv);

        QLabel *label = new QLabel("Hello, Qt!", 0);
        label->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
        label->setGeometry(10, 10, 200, 80);
        app.setMainWidget(label);
        label->show();

        int result = app.exec();
        return result;
}
~

編譯時錯誤如下:
[root@localhost hell]# make
gcc  -o hello hello.o  
hello.o: In function `main':
hello.cpp.text+0x31): undefined reference to `QApplication:Application(int&, char**)'
hello.cpp.text+0x41): undefined reference to `QString:String(char const*)'
hello.cpp.text+0x4d): undefined reference to `operator new(unsigned int)'
hello.cpp.text+0x73): undefined reference to `QLabel:Label(QString const&, QWidget*, char const*, unsigned int)'
hello.cpp.text+0x8d): undefined reference to `QString::shared_null'
hello.cpp.text+0x99): undefined reference to `QString::shared_null'
hello.cpp.text+0xa1): undefined reference to `QStringData::deleteSelf()'
hello.cpp.text+0xeb): undefined reference to `QApplication::setMainWidget(QWidget*)'
hello.cpp.text+0xfe): undefined reference to `QApplication::exec()'
hello.cpp.text+0x10: undefined reference to `QApplication::~QApplication()'
collect2: ld returned 1 exit status
make: *** [hello] Error 1

論壇徽章:
0
2 [報告]
發(fā)表于 2010-11-12 11:56 |只看該作者
回復 1# zhangyue8624

記得qt4頭文件包含應該是
#include <QApplication>
#include <QLabel>

論壇徽章:
0
3 [報告]
發(fā)表于 2010-11-12 16:47 |只看該作者
回復 2# cstdio


    我用qt-x11-2.3.2,頭文件沒問題,錯誤依舊。

論壇徽章:
1
黑曼巴
日期:2020-02-27 22:54:26
4 [報告]
發(fā)表于 2010-11-12 17:08 |只看該作者
提示: 作者被禁止或刪除 內容自動屏蔽

論壇徽章:
0
5 [報告]
發(fā)表于 2010-11-12 17:15 |只看該作者
ls說的對,你qt庫都沒鏈接進去。

論壇徽章:
0
6 [報告]
發(fā)表于 2010-11-12 17:23 |只看該作者
回復 4# c/unix


    我產生的makefile文件如下,里面有鏈接庫,QTDIR我設的是QT-x11的庫

####### Compiler, tools and options

CC      =       gcc
CXX     =       g++
CFLAGS  =       -pipe -Wall -W -O2 -DNO_DEBUG
CXXFLAGS=       -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG
INCPATH =       -I$(QTDIR)/include
LINK    =       gcc
LFLAGS  =
LIBS    =       $(SUBLIBS) -L$(QTDIR)/lib -lqte
MOC     =       $(QTDIR)/bin/moc
UIC     =       $(QTDIR)/bin/uic

TAR     =       tar -cf
GZIP    =       gzip -9f

論壇徽章:
0
7 [報告]
發(fā)表于 2010-11-12 17:24 |只看該作者
回復 5# cstdio


    請問如何把庫鏈接進去呢,我想用QT-x11的庫

論壇徽章:
0
8 [報告]
發(fā)表于 2010-11-12 17:34 |只看該作者
回復 7# zhangyue8624
-L/qtlib-path -lQtGui -lQtCore

既然是qt工程,你還是用.pro組織文件,方便又省心。

論壇徽章:
0
9 [報告]
發(fā)表于 2010-11-12 18:14 |只看該作者
回復 8# cstdio


    我就是用progen產生的hello.pro文件,然后用tmake產生的makefile,但我不太清楚了需要的庫在哪里加上,不會是每次有新工程都要手動加到makefile里面吧。。。

論壇徽章:
0
10 [報告]
發(fā)表于 2010-11-13 11:46 |只看該作者
qmake -project
qmake
make
這樣最簡單了。
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯網協會會員  聯系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP