Windows 10 Anniversary Update includes the Linux Subsystem for Ubuntu. I installed gcc with sudo apt-get install gcc
.
I wrote some simple C code for testing purposes:
#include <stdio.h>
int main(void){
printf("Hello\n");
return 0;
}
And compiled it with gcc -c main.c
but the execute (Linux only) main.o
is generated. If I run it ./main.o
, it displays Hello
.
My question is, how can I compile main.c
so that Windows can run it? Basically, how do you generate a *.exe
file with GCC in Linux Subsystem ?
compile Windows exe
...aren't they already executable? – Retrieval-c
option to the compiler you are explicitly telling it to perform the compilation step only -- and to not produce an executable by linking. – Eburnation* .exe
file should I just make sogcc -o main.exe main.c
? The fact is that when I do it and try to ran this output filemain.exe
I got this i.imgur.com/NUDCslM.jpg – Datura./main.exe
. If that works, then it seems that you might have linux executable, not windows. – Autogenousgcc -Wall -g main.c -o myprog
(this produces a Linux ELF executable) then run./myprog
– Joel