Windows 10 周年更新版包含了适用于 Ubuntu 的 Linux 子系统。我使用 sudo apt-get install gcc
命令安装了 gcc。
我编写了一些简单的 C 代码进行测试:
#include <stdio.h>
int main(void){
printf("Hello\n");
return 0;
}
我使用gcc -c main.c
编译完成,但只生成了(Linux系统上)可执行的main.o
文件。如果我运行./main.o
,它会显示Hello
。
我的问题是,怎样编译main.c
才能在Windows系统上运行?基本上,在Linux子系统中,如何用GCC生成一个*.exe
文件?