Ubuntu下可以直接安裝:
sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
安裝后編譯程序可以:
i586-mingw32msvc-g++(編譯C++程序)
i586-mingw32msvc-gcc(編譯C程序)
用法和gcc/g++非常類似。
如hello.c程序:
#include int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { MessageBox (NULL, "Hello", "Hello Demo", MB_OK); return (0); } |
編譯:
i586-mingw32msvc-gcc hello.c -o hello.exe -mwindows
注:-mwindows指示其編譯的是windows程序,若編譯的是console(命令行)程序,則不需要這個參數。
若安裝了wine,還可以測試一下這個程序:
wine hello.exe