Understanding the need for compilers for different platforms

I'm trying to find out how the whole assembly chain works, so I can better understand what happens when I create / link / compile, etc.

One problem I encountered is the following: if the compiler turns the source into its own assembly, why can't the same program work on different OS? Is the assembly performed directly by the processor? Thus, the same machine code should work on each OS, if it is the same architecture, no? Why not?

EDIT: . Most of the answers currently concern calling the OS APIs. This is obviously a problem. My question is about direct machine code . Is it transferred directly to the CPU or not? If I wrote the program in the assembly, would I still have to compile separately for each OS? (lateral point: if I used standard C ++ cin / cout, it depends on the OS, is it compiled for direct input / output of the assembly or does it depend on the response to the compiler?)

+5
source share
7 answers

(, ELF vs COFF), ( *.so, *.dll *.dylib, , , ) , .

, , Single UNIX Specification/IEEE Std. 1003.1 (POSIX), ( , - , Windows - ). ( ), - (-), ( , ... ). , (LLVM) .

+8

API ABI.

, . , POSIX fork execv , Windows CreateProcess.

, . ? . , .

, , - concurrency , . , - . , . API- , . , , .

+8

, , . Linux/x86, Windows Mac/Intel ( ), .

, , , , , , .

. UNIX, brk sbrk. C, UNIX.

, Windows Win32GetMem, .

+5

, . - .

, , , , , . , , Windows XP Solaris x86, , .

, . , , GNU GCC, .

+1

. 32- "x86", , . , , . ,

0

, . , Windows Linux Wine. . , , , . , , , .

0

: " , , ?" . , . / , - . , , "X" "A" "Y" "A", , ( ) (- , ).

0

All Articles