1.简述
这篇文章主要说明的是将linux上编译的程序放到windows上运行。
2.操作方法
2.1 下载必备的交叉编译软件
首先,我的主机与虚拟机都是64位的,虚拟机为ubuntu。
$ sudo apt-get install mingw-w64
2.2 编写程序
编写一个简单的测试程序:
#include <stdio.h>
int main(int argc,char *argv[])
{
printf("hello world\r\n");
while(1);
return 0;
}
2.3 编译程序
$ x86_64-w64-mingw32-gcc hello.c -o hello.exe
然后将虚拟机做如下设置:
配置文件共享
使用如下方法将exe拷贝到windows上:
$ cp hello.exe /mnt/hgfs/Desktop/
将程序拷贝到windows上。
2.4 执行程序
按照windows上的程序执行方法,执行该hello.exe即可。
---------------------
作者:weixin_34185320
来源:CSDN
原文:https://blog.csdn.net/weixin_34185320/article/details/87119397
版权声明:本文为博主原创文章,转载请附上博文链接!