I'm just curious if this is posible: Is there C++ compiler that runs on windows and can generate Linux code?
GCC compiler is used to compile and run a C program on the Linux operating system. We can use the in-build text editor or other editors like Visual Studio Code or Sublime Text to write our C Programs.
If you want to run C or C++ programs in your Windows operating system, then you need to have the right compilers. The MinGW compiler is a well known and widely used software for installing GCC and G++ compilers for the C and C++ programming languages.
Is there a way to compile the program on Linux (i.e. Ubuntu) is such a way that the .exe file can just run on Window without any need to recompile it on Windows? Yes. To build a program on linux which runs on Windows, you need to use a cross-compiling tool chain which builds code with links to Windows run-times.
The g++ cross compiler can do that.
See http://metamod-p.sourceforge.net/cross-compiling.on.windows.for.linux.html.
Absolutely it's possible. You need a compiler that can handle cross-compilations and then specify the target. The key point is to get a compiler that's capable of creating the binary files in a manner required by the target system. g++ would do just that for you.
I worked on a project where we used linux to create embedded arm executables using their C compiler, and then used scp to copy it over for testing.
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