Ubuntu下可以直接安装mingw(sudo apt-get install mingw32 mingw32-binutils mingw32-runtime,附例子,简单好用,亲测成功)good

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 "windows.h"
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

http://tieba.baidu.com/p/733815195

http://www.cnblogs.com/lvdongjie/p/3763032.html

------------------------------------------------------------------

whereis i586-mingw32msvc-gcc

结果发现2个:/usr/bin 和 /usr/bin/X11,也不知道在我安装mingw之前,是否已经存在。

另外,我觉得这个安装的是mingw-w32,而不是mingw

另外,我在/usr/amd64-mingw32msvc和/usr/i586-mingw32msvc两个目录,也不知道在我安装mingw之前,是否已经存在。

到底mingw-w32到底安装到哪里了?目前 /opt 目录是空的。应该在纯净Linux下运行whereis 和 ls /usr 和 ls /opt

i586-mingw32msvc-gcc -v可以观察到很多信息。

原文地址:https://www.cnblogs.com/findumars/p/7492627.html