I was trying to run a program, compiled on Linux on a windows machine(just for fun). I understand that a dynamically linked executable cannot be run on windows because of the linux c library, and windows gives some error saying something about illegal instructions. I then tried running the statically linked application, now windows is not giving me any errors, but it still is not giving the correct output, a command prompt windows appears and disappears after an instant. But the way I see it, I should be able to run a statically linked application on any x86 computer irrespective of the OS.
I compiled code using:
gcc -static loop.c
file ./a.out gives the result
./a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.15, not stripped
Source Code of the sample program:
int i = 0;
printf("%d \n", i++);