Mingw:在Linux系統下編譯Windows的程序


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM