一开始用源代码编译,然后安装的,安装到 /usr/local/Trolltech/Qt-4.5.0 目录下,编译了一个小程序,失败,找不到头文件之类的,刚接触ubuntu,根本不东哪里配置环境变量,更不知道怎么配置。
然后删掉重装,用 apt-get install 命令从网络直接安装的 QT 开发包,安装完之后目录在哪里我都不知道了,以为这样就可以自动配置所有的环境变量,结果错误还是依旧,我搞了两天快头疼死了,linux怎么就这么麻烦???????????
程序如下:
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello Ubuntu!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
开发工具用的Code::Blocks,用命令行编译错误也是类似:
/home/daotong/QTest/main.cpp|1|错误: QApplication:没有该文件或目录|
/home/daotong/QTest/main.cpp|2|错误: QPushButton:没有该文件或目录|