Cross-Compiling C and C++ application in Windows 7, using MinGW under linux
I have installed MinGW compiler in Windows 7. GCC version is 4.6.1.
I have Hello World application:
#include <stdio.h>
int main( int argc, char* argv[] )
{
printf( "Hello World!" );
开发者_StackOverflow中文版return 0;
}
How I can compile this application under Windows 7, using MinGW compiler, in order that i can run this application in linux, without recompile.
You need to distinguish two systems here: The build system, which is the one your compiler runs on, and the host system, which is the one your executable will run on. MinGW is the GCC compiler for the host system Windows. So, you can compile on Windows for Windows or cross-compile on Linux for Windows. You are looking for a cross compiler for build Windows to host linux, which might be included in Cygwin.
However, generally such things are not well-supported, since Windows is normally used as an end-user only system, not for developing, and UNIX systems for developers. So, you are compiling against the stream here, something not too many people do.
I don't think MinGW provides any cross-compilers that are able to produce linux binaries.
This can be done using Cygwin, they provide cross-compilers so that you can compile linux binaries on a Windows host. You just need to install the necessary packages.
精彩评论