如果刚开始学qt,还处于
c++语法学习阶段,在
Windows下,只安装qt
sdk(或分别安装framework+qt creator)的情况下,如何编写标准c++程序呢?分享一下经验,给像我一样的
新手。。。
之前,我
安装了dev-cpp,其实它也是基于mingw的,而qt sdk开源版已经包含了mingw,其实我们只需要通过修改一下环境变量就可以了。
假设qt creator安装路径为:D:\Software\QtSDK\qtcreator,该
目录下有一个mingw的目录,右键单击“我的电脑”>“属性”>“高级”选项卡>"环境变量">"系统变量“>Path。在Path中添加路径D:\Software\QtSDK\qtcreator\mingw\bin即可。
在命令行
窗口下,就可以使用gcc来
编译标准C++程序了,例子:
//content of file "try.cpp"
#include <iostream>
using namespace std;
int main()
{int i(1),j(1);
char b;
cout<<"hello qt"<<endl;
for(i=1;i<10;i++)
{for(j=1;j<=i;j++)cout<<"*";
cout<<" "<<"***--->";
cout<<endl;
}
for(i=10;i>=0;i--)
{for(j=1;j<=i;j++)cout<<"*";
cout<<" "<<"***--->";
cout<<endl;
}
cout<<"Input any charater to end"<<endl;
cin>>b;
cout<<b;
}
写完源代码后编译命令:g++ try.cpp -o try.exe(或gcc try.cpp -o try.exe -lstdc++)
运行:try.exe
[ 此帖被yejustme在2011-02-01 20:04重新编辑 ]