Question

If the compiler converts the high level language (like C++, for example) to the machine code to be executed by the Microprocessor.

Why can't the programs which run on Windows run on Mac or Linux?

Was it helpful?

Solution

As long as a high-level program really is written 100% in C++ or another language and uses no external code at all, it is in fact relatively easy to make it compile on any OS with a compiler, and it will behave in the same way.

The difficulty is that virtually every program uses libraries of the OS, e.g. for Input/Output, UI drawing etc., and these are different on every OS under the sun. In practice, it is impossible to get anything realistic done in a computer program without taking advantage of the massive amount of helper code present in the OS, or in libraries shipped with the OS. This is what makes porting harder - usually not actually difficult, just tedious.

OTHER TIPS

Because a lot of your calls are referencing elements of the OS. Like drawing, acessing the filesystem. These calls have to be translated, like Java or Qt.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top