qt编译出错 环境变量添加过了,可还是出错,好像是库的问题

出现如下错误信息:
think@ubuntu:~/桌面/qt-book/chap01/hello$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -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
hello.cpp:1:24: error: QApplication: 没有那个文件或目录
hello.cpp:2:18: error: QLabel: 没有那个文件或目录
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:6: error: ‘QApplication’ was not declared in this scope
hello.cpp:6: error: expected ‘;’ before ‘app’
hello.cpp:7: error: ‘QLabel’ was not declared in this scope
hello.cpp:7: error: ‘label’ was not declared in this scope
hello.cpp:7: error: expected type-specifier before ‘QLabel’
hello.cpp:7: error: expected ‘;’ before ‘QLabel’
hello.cpp:9: error: ‘app’ was not declared in this scope
hello.cpp: At global scope:
hello.cpp:4: warning: unused parameter ‘argc’
hello.cpp:4: warning: unused parameter ‘argv’
make: *** [hello.o] 错误 1

Linux下面编译Qt程序的步骤应该是这样的:
1.进入源文件的目录
2.qmake -project
3.qmake
4.make

注意你的qmake一定是系统可以找到的程序。如果环境变量没有添加,或者你希望手动选择使用的qmake,可以直接在你安装qt目录的/bin/qmake 来代替qmake

希望解决你的问题,如果还有问题,请追问。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-10-09
既然你是用Ubuntu,你可以使用Ubuntu中文论坛里面的
http://wiki.ubuntu.org.cn/index.php?title=Qt&variant=zh-cn
这里有一套教你如何配置qt的开发环境(图形界面)。
《QT4图形设计与嵌入式开发》这本书很适合初学者学习。
第2个回答  2010-10-09
错了的话,可以把杀毒杀一下就行了!
第3个回答  2010-10-13
最好不要有中文路径。
相似回答
大家正在搜