Windows XP下MinGW的安裝與配置
到http://sourceforge.net/projects/mingw/ 手動去下載最新的MinGW,或使用MinGW-5.1.4.exe,自動下載。但後者往往不能下載到最新的穩定包。
1、手動下載說明,參見:http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite
可從:http://sourceforge.net/projects/mingw/ 選擇包下載。
2、運行 MinGW-5.1.4.exe 的話,選擇 Candidate,一般會下載最新的包,選擇如下幾項:
MinGW base tools
g++ compiler
MingGW Make
預設路徑C:/MinGW,我裝在 D:/cplusplus/mingw
根據:http://wiki.codeblocks.org/index.php?title=MinGW_installation,需要下載如下必要的包:
* http://prdownloads.sf.net/mingw/gcc-core-3.4.5-20060117-1.tar.gz
* http://prdownloads.sf.net/mingw/gcc-g++-3.4.5-20060117-1.tar.gz
* http://prdownloads.sf.net/mingw/mingw-runtime-3.9.tar.gz
* http://prdownloads.sf.net/mingw/mingw-utils-0.3.tar.gz
* http://prdownloads.sf.net/mingw/w32api-3.6.tar.gz
* http://prdownloads.sf.net/mingw/binutils-2.17.50-20060824-1.tar.gz
* http://prdownloads.sf.net/mingw/mingw32-make-3.81-1.tar.gz
另外一個是調試器:
* http://prdownloads.sf.net/mingw/gdb-6.3-2.exe
安裝完後就配置環境變數吧。
控制台--〉系統--〉系統詳細設定--〉環境變數
MINGW_PATH=D:/cplusplus/mingw
C_INCLUDE_PATH=%MINGW_PATH%/include;%MINGW_PATH%/lib/gcc/mingw32/3.4.5/include
CPLUS_INCLUDE_PATH=%MINGW_PATH%/include/c++/3.4.5;%MINGW_PATH%/include/c++/3.4.5/mingw32;%MINGW_PATH%/include/c++/3.4.5/backward;%C_INCLUDE_PATH%
LIBRARY_PATH=%MINGW_PATH%/lib;%MINGW_PATH%/lib/gcc/mingw32/3.4.5
PATH=%MINGW_PATH%/bin;%MINGW_PATH%/libexec/gcc/mingw32/3.4.5
注意:上面的很多3.4.5這個是gcc的版本號碼,要以真實的檔案夾為準。
現在開一個CMD吧
輸入g++ --version
看到以下資訊的話就成功一半了。
Reading specs from D:/cplusplus/mingw/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --wi
th-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --dis
able-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --d
isable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --with
out-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enabl
e-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5 (mingw-vista special r3)
繼續建立一個test.cpp檔案
內容如下
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "Yeah, MinGW!" << endl;
return 0;
}
在cmd下面輸入編譯命令
g++ -o test test.cpp
這次是什麼都沒看到就是成功了。
接著輸入test.exe
看見以下的資訊了麼
Yeah, MinGW!
現在,可以在XP下面編寫你的C或者C++程式了。