3

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.

2
  • 4
    ELF and PE executable formats are not really the same binary formats. Commented Sep 16, 2011 at 8:37
  • Are MinGW allow to cross-compile application? Commented Sep 16, 2011 at 8:46

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.