分页: 1 / 1

QT编译错误,求解

发表于 : 2009-11-09 11:33
wangjun403
C++ GUI Programming with Qt 4英文原版书上第二章的例子:Chapter 2. Creating Dialogs Rapid Dialog Design
完全按书上写的代码

wangjun@wj-dt:~/qt/qt-book-test/chap02/gotocell2$ ls
gotocell2.pro gotocelldialog.h main.cpp
gotocelldialog.cpp gotocelldialog.ui


qmake -project
qmake-qt4 gotocell2.pro
然后make

代码: 全选

wangjun@wj-dt:~/qt/qt-book-test/chap02/gotocell2$ make
/usr/bin/uic-qt4 gotocelldialog.ui -o ui_gotocelldialog.h
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
g++ -Wl,-O1 -o gotocell2 main.o    -L/usr/lib -lQtGui -lQtCore -lpthread
main.o: In function `main':
main.cpp:(.text+0x51): undefined reference to `GoToCellDialog::GoToCellDialog(QWidget*)'
collect2: ld returned 1 exit status
make: *** [gotocell2] 错误 1
开始以为自己那里抄写错误,就在网上下了源代码后直接编译,也是提示这个错误
我就接着编译其他例子,也会提示这种错误
这种情况就应该是为自己Qt的问题了

求助!!!

Re: QT编译错误,求解

发表于 : 2009-11-10 22:53
liguanyao
我的情况跟你差不多啊。。
lee@lee-laptop:~/c$ make
/usr/bin/qmake-qt4 -unix -o Makefile c.pro
gcc -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o micro.o micro.c
micro.c: In function ‘main’:
micro.c:16: error: expected expression before ‘[’ token
micro.c:20: error: subscripted value is neither array nor pointer
micro.c:23: error: expected declaration or statement at end of input
micro.c:23: error: expected declaration or statement at end of input
make: *** [micro.o] 错误 1
好心人帮忙~

Re: QT编译错误,求解

发表于 : 2009-11-13 10:14
sclzmbie
那是因为GoToCellDialog()这个函数你还没实现呢。
看下一章,就有了。

Re: QT编译错误,求解

发表于 : 2009-11-17 8:50
md5xwl
我的是提示ld error:not find -lqt;

Re: QT编译错误,求解

发表于 : 2010-01-28 8:17
tusooa
我的可以啊,你执行

代码: 全选

qmake-qt4 -project &&
qmake-qt4 &&
make
看看

Re: QT编译错误,求解

发表于 : 2010-09-05 23:21
black_cx
没有错误的!