2
votes

I have a Linux program that I want to run on Windows. I want to compile it for Windows using Mingw? I am new to this Mingw thingy. So, I have no idea if it will work.
I installed Mingw and I have a make file. What's next? I have a bunch of exe files in Mingw. I don't even know how to start the compiler.

So, my question is: What are the steps necessary to compile the program I have?


UPDATE:

I figured out in the end what are the steps necessary to compile a Linux program for Win using Mingw.
I posted the solution below (solution is 7 steps), maybe it will be useful to others also.

1
Maybe that will work too. But it will be so nice to have a Win exe file (with MingW).Server Overflow
cygwin will make a win exe.drescherjm
You would have Windows' executable from both solutions of course. But executable produced by Cygwin will need Cygwin's DLL to execute. Executable from Mingw will be fully standalone.David Ferenczy Rogožan
Except where the MinGW executable needs one or more of the MinGW DLLs. Using Cygwin will solve many problems with porting Linux programs to Windows.Ross Ridge
@Executable from Mingw will be fully standalone - I don't think so. For example my exe needs libgcc_s_dw2-1.dll (after compiling with Mingw).Server Overflow

1 Answers

3
votes

To compile a Linux program on Win:

  1. Install MingW
  2. Edit the c:\MinGW\msys\1.0\etc\fstab file (it should contain this line: c:/mingw /mingw )
  3. Start Wingw shell by running c:\MinGW\msys\1.0\msys.bat
  4. In shell go to the folder where your Make file is (use cd command for this).
  5. Type 'make'. This will compile your program.
  6. Put the generated EXE and the required DLLs (libgcc_s_dw2-1.dll and libstdc++-6.dll) in the same folder
  7. Run the exe file and enjoy it....