Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!" );
    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.

like image 550
G-71 Avatar asked Jan 01 '26 10:01

G-71


1 Answers

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.

like image 172
thiton Avatar answered Jan 03 '26 03:01

thiton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!