Is it possible to create binaries of other platform on Linux? Say I have a program that can be compiled using gcc to .o
file but can we use it to output exe
that can be run on windows ?
Short version: yes, you can. This is called cross-compiling and any search on google with this keyword will give you adequate results.
Now the reality:
It takes quite the effort to have even a relatively small piece of c/c++ code running on both platforms. Differences in API's, user interfaces, calling conventions, alignments and much more are common practice.
Fortunately there are a lot of cross-platform tools that can help you. Google for Qt, a cross-platform user interface library. Or use Boost when and where you can.
You'll probably need to add numerous #ifdef __WINDOWS__
or #ifdef __UNIX__
(these statements might be incorrect) to specify separate lines of code for each platform.
So it is not a sinecure to code for both platforms and, depending on the complexity of the software you're writing, requires in-depth knowledge of operating systems in general and both OS'es in particular.
In other words: there's no tool that makes an .exe out of your .o, just like that.
Good luck!
~Rob
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With