标题:Qt下的make编译老是出错
作者:hmilyylimh
日期:2011-04-22 09:46
内容:
程序如下:#include
#include
int main(int argc,char **argv)
{
qapplication a(argc,argv);
qlabel *label=new qlabel("hello world!",0);
label->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
label->setGeometry(10,10,200,80);
app.setMainWidget(label);
label->show();
int result=app.exec();
return result;
}
我的qt安装在/tmp下,在网上搜索了一下,我还安装了g++,编译时出错如下:
执行命令:progen -t app.t -o hello.pro
tmake -o makefile hello.pro后,ls一下:
hello.cpphello.promakefile
然后执行命令:make,出现的错误有:
hmily@xtu:~/文档/HELLO$ make
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/usr/include/qt -o hello.o hello.cpp
hello.cpp:1:26: error: qapplication.h: 没有那个文件或目录
hello.cpp:2:20: error: qlabel.h: 没有那个文件或目录
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:5: error: ‘qapplication’ was not declared in this scope
hello.cpp:5: error: expected ‘;’ before ‘a’
hello.cpp:6: error: ‘qlabel’ was not declared in this scope
hello.cpp:6: error: ‘label’ was not declared in this scope
hello.cpp:6: error: expected type-specifier before ‘qlabel’
hello.cpp:6: error: expected ‘;’ before ‘qlabel’
hello.cpp:7: error: ‘Qt’ has not been declared
hello.cpp:7: error: ‘Qt’ has not been declared
hello.cpp:9: error: ‘app’ was not declared in this scope
hello.cpp: At global scope:
hello.cpp:3: warning: unused parameter ‘argc’
hello.cpp:3: warning: unused parameter ‘argv’
make: *** 错误 1
而且后来我把qt里的qapplication.h,qlabel.h复制到HELLO目录下,则出现的错误为:
hmily@xtu:~/文档/HELLO$ make
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/usr/include/qt -o hello.o hello.cpp
hello.cpp:1:26: error: qapplication.h:..
#1 [jyzjut 04-22 12:52]
我也遇到了这个问题,很纠结的
#2 [XChinux 05-10 23:20]
没有找到头文件,你的/usr/include/qt目录下确认有qapplication.h文件吗?
按照正常Qt开发模式来开发吧,用qmake来生成Makefile