I am developing an application that will have to run on both Windows and Linux.
So far I have it running on Linux using GCC 4.4.1 using my Makefile.
However, I also need to compile on Windows. The source code will compile on Windows as I have #defined all the areas of the code that separate the different compilers. I.e.:
#ifdefined (LINUX)
/* Do linux stuff */
#else
/* Do windows stuff */
#endif
And so far the code is very simple as I am just starting this program. Basically I just want to test my idea.
However, is it as simple as compiling the source code on Linux?
Then when I want to compile on to Windows I could copy the files to the Windows platform. Then opening the source code files in Visual Studio C++ and creating a project and then compiling to create my binary?
Compile to Linux from Windows without to use virtualization or cross compiler but only natively via CoLinux. Create native Linux executable files without leave (reboot) windows. C/C++ Compiling for Linux under Windows through Cooperative Linux.
mingw32 exists as a package for Linux. You can cross-compile and -link Windows applications with it. There's a tutorial here at the Code::Blocks forum. Mind that the command changes to x86_64-w64-mingw32-gcc-win32 , for example.
Cross-compilation is the act of compiling code for one computer system (often known as the target) on a different system, called the host. It's a very useful technique, for instance when the target system is too small to host the compiler and all relevant files.
GCC (and GNU Toolchain) is currently available on all Unixes. They are also ported to Windows (by Cygwin, MinGW and MinGW-W64). GCC is also a cross-compiler, for producing executables on different platform.
Using Visual C++ is one way of building your C project on Windows. It's not the only way, though.
VC has project files that you will need to create. But then realize that you'll have to maintain the build configuration in two different places (make & .vcproj).
There are other options as well:
If I were you I'd try to use as few different build tools as possible.
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