How to install MinGW with Geany

I just started to learn C++ and finding a good compiler for windows Vista isn’t as easy as I thought it would be. Even more, after I found one it didn’t really work on its own. Offcource you can find lots of information how to get it running if you google a little bit, but even then it was hard for me to get it up and running. Because I know that I’m not the only leek in the world who is learning C++, I written a small tutorial in human language. Here you can read how you install MinGW and get it up and running together with Geany under Windows Vista. I did this under the “home premium” edition of Vista, so the change is big this will work under other versions as well. (and hopefully also under VISTA SP1)

Part 1. Installing MinGW.

First we are going to install MinGW, the best way to do this, is using the MiniGW Auto Installer.

  • Download it and execute it (I can all hear you thinking: “duh”)
  • Select download and install and click next (fig.1)
  • Agree to the license Agreement
  • Chose the current version
  • At this step you can chose the components you need, check the g++ compiler like in the screenshot (fig.2), for now this is more then enough, if you need more components in the future, you always can run the installer again and add more components.
  • Use the default destination folder (C:\MinGW)
  • A few more clicks on “next” and then “install”.

If all went well it will download all the packages and install them, this was the fun part :-)

  • Now, go to start (the windows icon in the bottom left corner -_- ), right click on “Computer” and chose “properties”
  • Under task you click “Advance system settings”, normally you will get a a window like in the screen’s (fig.3)
  • Go to the “Advance”-tab and click on “Environment Variables…”
  • Look in your “system variables” for “Path“, select it and hit “Edit..” (fig.4)
  • In the “Variable Value” you add “;c:\mingw\;c:\mingw\bin;c:\mingw\libexec\gcc\mingw32\3.4.5\;”, be sure that the 3.4.5 is the same as your MinGW version.
  • Hit “OK” a few times and close down all windows.
  • In your explorer, go to “C:\MinGW\libexec\gcc\mingw32\3.4.2″. Copy all the files in that folder to “C:\MinGW\bin”

And that’s all for the first part, go ahead and open a Command line window and enter “g++ –version”
Note: be sure to open a NEW Command line window and when you compile, compile, be sure to place the source files under your C-drive, for some reason you can’t compile from a different partition.

2. Install Geany.

Geany isn’t necessary, but its a good and light weighted IDE that will make programming (and compiling) more a hell job ;-)
The good news is that you can use it on *nix, Mac and Windows, the bad news is that your make a few adjustments under windows to make it “perfect”.

  1. Download the win32 build for geany from there website and install it.
  2. After the install, run it an make a new “c++ source file”
  3. Go to Build -> Set Includes and Arguments.
  4. Change the compile settings from g++ -Wall -c “%f” to
    g++ -m32 “%f” -o “%e.exe”
  5. Change the Build settings from g++ -Wall “%f” to g++ -m32 “%f” (fig.5)
  6. And hit OK. That’s it

What does this do? If you use the default settings, geany will compile it to a *.o file and since we can’t use a *.o file under windows, we need to compile it to a windows program.

Thanks for reading this, I hope it will help some people and that there aren’t to many spellings errors ;-)
I would like to thank the people of MiniGW, Geany and Aaron Giles for all the help.
If you have any question, feel free to post them in the comments or contact me.

10 Responses to “How to install MinGW with Geany”

  1. Federico says:

    thanks a lot man! btw, in my system, the compile and build settings
    had to be configured without the “” for it to work: compile = g++
    -m32 %f -o %e.exe build = g++ -m32 %f thanks again!

  2. Ithelp says:

    It doesnt work for me! I’ve followed every step but cannot compile
    for c. y changed g++ for gcc as well and it wont work! please i
    need some help! thanks a lot

  3. Pedro O. says:

    Thanks, very much.

  4. IK says:

    hey. thanks a lot for this. really helped. but this one’s just for
    c++ compilations. what am i suppose to do for c compilations and

  5. Anatoliy Leonov says:

    Thanks you a lot! Really good manual!

  6. feca1997 says:

    I did exactly the same and it worked(but it was slow) with the old
    compiler and build settings. After I changed them this happened:
    g++ -m32 “osszeg.cxx” -o “osszeg.exe” (in directory:
    C:\Users\Feca\Dropbox\Public\Programming\C++\iskolai) g++.exe:
    error: osszeg.cxx : No such file or directory g++.exe: fatal error:
    no input files compilation terminated. Compilation failed.

  7. Stijn says:

    Hi feca1997 I don’t use geany anymore, but I tried it under a
    virtual machine using Windows 7 and a simple HelloWorld example. It
    worked perfect. Do note that the quotes need to be ” and not “ or ”
    that’s a mistake by wordpress.

  8. nurfan says:

    my problem solve. thanks you a lot.

  9. PRAMOD says:

    hey its not working .. it is still showing compilation failed. i am using windows xp. i did exactly what you said…

  10. Jack says:

    MinGW is painful.

    After installation I have had many problems.

    The latest one is that when I try to open it I get the message – cannot open this programme in PAINT.

Leave a Reply