Windows XP下MinGW的安裝與配置

來源:互聯網
上載者:User

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++程式了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.