Can this C program , that uses purely an unlinked C stdlib and is compiled for Linux, run on Windows?

The question is a bit specific, so assume the following:

  1. The program's C source code does not explicitly use platform-specific functions (it does not explicitly use system calls, for example).
  2. To interact with the OS, the source code uses the C stdlib.
  3. The stdlib is not linked at compile time.
  4. The program was compiled for Linux on a machine running Linux, then moved to another machine running Windows.
  5. Before executing the program on Windows, the Linux executable is (somehow) converted to a format compatible with Windows.
  6. Both machines have the same hardware.
  7. Both machines have a implementation of the C stdlib.

Now for the question(s):

  1. Given all the assumptions above, can the program execute on Windows? If not, why?
  2. If there's an assumption that is incorrect, why is that?

The binaries on Windows and Linux have very different format, so one cannot run on the other. Linux shared libraries are not at all the same as Windows DLL.

Cross-system execution is achieved by either of:

  • Re-compilation for the target system (many compilers are capable of compiling on system A for execution on B)
  • Running on an emulator, such as WINE, CrossOver and others
  • Running in a virtual machine, Windows Subsystem for Linux (WSL), Docker or similar.

No. The executable format of Linux is not compatible with Windows. You would have to recompile the program for Windows.

Alternatively, you could run the program natively in the Windows Subsystem for Linux or in a Virtual Machine running Linux.