Search code examples
c++linuxwindowscygwinmingw

How to compile a Linux program with Mingw?


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.


Solution

  • 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....