win7 32bit 用qmake编译qt程序

来源:互联网 发布:个体户 域名备案 编辑:程序博客网 时间:2024/06/03 06:32

一、环境变量的设置

首先检查cl 环境配置是否正确。

windows键 + R 打开“运行”,输入 cmd 。再输入cl。

(1)若提示cl 不是外部或内部命令什么的,就要在Path 中添加:%prefix%\Microsoft Visual Studio 10.0\VC\bin (其中%prefix%是安装路径)

(2)若运行后提示缺少mspdb100.dll ,就要在Path 中添加:%prefix%\Microsoft Visual Studio 10.0\Common7\IDE (其中%prefix%是安装路径)

二、编译程序

配置vc , 打开命令行,cd 到以下目录 %prefix%\Microsoft Visual Studio 10.0\VC\bin

运行 vcvars32.bat 。

cd 到qt工程目录下,创建自己的cpp 文件。

//hello.cpp#include<QApplication>#include<QLabel>int main(int argc, char *argv[]){QApplication app(argc,argv);QLabel *label = new QLabel("Hello Qt");label->show();return app.exec();}

命令行输入以下命令,生成pro 文件。

qmake -project

命令行输入以下命令,生成makefile文件。

qmake hello.pro

再运行nmake即可

nmake         //debug 编译nmake release //release 编译

编译成功,生成exe。


0 0