I\'ve learned the basics about CPUs/ASM/C and don\'t understand why we need to compile C code differently for different OS targets. What the compiler does is create Assemble
You might want to check the other answers.
Its kind of duplicate question except that its for C not C++
You can check process of compilation steps here:
C compilation steps
In short , even though C is can be cross platform to run, due to compilers its not cross-platform compile-able.