在Ubuntu上編譯生成Windows程序

安裝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
發佈了50 篇原創文章 · 獲贊 15 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章