• 4907阅读
  • 1回复

[讨论]Qt下的make编译老是出错 [复制链接]

上一主题 下一主题
离线hmilyylimh
 
只看楼主 倒序阅读 楼主  发表于: 2011-04-22
程序如下:#include <qapplication.h>
#include <qlabel.h>
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.cpp  hello.pro  makefile
然后执行命令: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: *** [hello.o] 错误 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: 没有那个文件或目录
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: *** [hello.o] 错误 1
所以我很郁闷,还请各位大侠帮帮忙解决一下问题...非常感谢...
离线dbzhang800

只看该作者 1楼 发表于: 2011-04-22
我对这个东西不了解,但可以确定基本环境搭建有问题。

按你所说,安装在 /tmp (对了,临时目录是用来安装程序的么?)

可是你的生成的makefile中却指向 /usr/include/qt
快速回复
限100 字节
 
上一个 下一个