在Ubuntu上编译生成Windows程序

来源:互联网 发布:阿里巴巴代销传淘宝 编辑:程序博客网 时间:2024/06/18 17:27

安装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
原创粉丝点击