安裝mingw32
`$ sudo apt-get install mingw32
我的是ubuntu16.04,沒有找到mingw32
,如果源裏面沒有mingw32
的話,打開/etc/apt/sources.list
$sudo vim /etc/apt/sources.list
加上一行
deb http://us.archive.ubuntu.com/ubuntu trusty main universe
然後
$sudo apt-get update
$sudo apt-get install mingw32
編譯
自己編一個簡單的C/C++程序,如
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
cout<<"hello"<<endl;
string a;
cin>>a;
return 0;
}
然後就用i586-mingw32msvc-g++
編譯,用法和g++
是一樣的
$i586-mingw32msvc-g++ hello.cpp -o hello.exe