QT4编译问题(持续更新)

1. Hello Qt
问题:
 jason@jason-desktop:~/my_doc/qt/test/chap01/hello$ qmake -project
jason@jason-desktop:~/my_doc/qt/test/chap01/hello$ qmake
jason@jason-desktop:~/my_doc/qt/test/chap01/hello$ make
g++ -c -pipe -g -Wall -W -O2 -D_REENTRANT  -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o hello.o hello.cpp
hello.cpp:15:24: error: QApplication: 没有该文件或目录
hello.cpp:16:18: error: QLabel: 没有该文件或目录
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:20: error: ‘QApplication’ was not declared in this scope
hello.cpp:20: error: expected ‘;’ before ‘app’
hello.cpp:21: error: ‘QLabel’ was not declared in this scope
hello.cpp:21: error: ‘label’ was not declared in this scope
hello.cpp:21: error: expected type-specifier before ‘QLabel’
hello.cpp:21: error: expected ‘;’ before ‘QLabel’
hello.cpp:23: error: ‘app’ was not declared in this scope
hello.cpp: At global scope:
hello.cpp:18: warning: unused parameter ‘argc’
hello.cpp:18: warning: unused parameter ‘argv’
make: *** [hello.o] 错误 1
jason@jason-desktop:~/my_doc/qt/test/chap01/hello$

原因:
QT3与QT4版本之间不兼容问题。QT4的代码用QT3编译

解决:
jason@jason-desktop:~/my_doc/qt/test/chap01/hello$ qmake-qt4 -project
jason@jason-desktop:~/my_doc/qt/test/chap01/hello$ qmake-qt4
jason@jason-desktop:~/my_doc/qt/test/chap01/hello$ make
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. -o hello.o hello.cpp
g++ -Wl,-O1 -o hello hello.o    -L/usr/lib -lQtGui -lQtCore -lpthread
jason@jason-desktop:~/my_doc/qt/test/chap01/hello$

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IOT物联网小镇

赏点银子去植发

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值