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”.
- Download the win32 build for geany from there website and install it.
- After the install, run it an make a new “c++ source file”
- Go to Build -> Set Includes and Arguments.
- Change the compile settings from g++ -Wall -c “%f” to
g++ -m32 “%f” -o “%e.exe”
- Change the Build settings from g++ -Wall “%f” to g++ -m32 “%f” (fig.5)
- 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.