Difference between revisions of "Installing MinGW with Vista"

From Code::Blocks
(Initial version - still work in process)
 
Line 11: Line 11:
 
* I assumed you are going to install in C:, if you want to install on another partition (which may be clever as the sources must be on the same partition) you'll have to modifie the path acordingly
 
* I assumed you are going to install in C:, if you want to install on another partition (which may be clever as the sources must be on the same partition) you'll have to modifie the path acordingly
 
* I used ''MinGW-Version'' to indicate that you musst use your Version of MinGW here. As you can see on my pictures it is for me 4.2.0 and for those who downloaded on [[http://mingw.org]] ist is most probably 3.4.2
 
* I used ''MinGW-Version'' to indicate that you musst use your Version of MinGW here. As you can see on my pictures it is for me 4.2.0 and for those who downloaded on [[http://mingw.org]] ist is most probably 3.4.2
 +
 +
Just one thing left: I've done this under Vista Bussines. I hope it works on the other versions, too, an I'll ask a friend of mine to test it under Home Premium
  
 
== Getting MinGW ==
 
== Getting MinGW ==

Revision as of 18:13, 27 June 2007

Bevore we start

Bevore starting to install MinGW under Windows Vista there are some things to remember:

  • MinGW must be located on the same partition as the files you want to compile
  • There may be issues if you don't install MinGW in the toplevel folder (e.g. C:\MinGW) but in some folder (e.g. C:\Compilers\MinGW)

For this HOWTO I used some Conventions:

  • I assumed you are going to install in C:, if you want to install on another partition (which may be clever as the sources must be on the same partition) you'll have to modifie the path acordingly
  • I used MinGW-Version to indicate that you musst use your Version of MinGW here. As you can see on my pictures it is for me 4.2.0 and for those who downloaded on [[1]] ist is most probably 3.4.2

Just one thing left: I've done this under Vista Bussines. I hope it works on the other versions, too, an I'll ask a friend of mine to test it under Home Premium

Getting MinGW

First of all you need the MinGW Compiler installed. I used the installer but all methods desciribed under MinGW installation should work fine. You may althoug want to upgrade your Version of MinGW to 4.*. When you finished installing the basic MinGW we'll start making it work with Windows Vista. (Note: There is no need to set any %PATH% - Variable when you use only Codeblocks, this is the way I'll focuse on)

Actual Setup

Executeables

If you haven't already done it it is time to install and start Code::Blocks. It's a good idea to creakte a sample Consoleapplication so you have a basic "Hello world" to test your progress. As I first tried to run "Compile" without any Modifications I got the following Error:

-------------- Build: Debug in test ---------------
Compiling: main.cpp
mingw32-g++.exe: CreateProcess: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

This does tell us very little. The problem here actually is, that MinGW is unable to find its helper executeables, in this case cc1plus.exe. To fix this go to your "Settings" -> "Compiler and Debugger" -> "Toolchain executeables" -> "Additional paths" and add there the Directory "C:\MinGW\libexec\gcc\mingw32\MinGW-Version where MinGW-Version is the Version of MinGW you are using. If you use a unmodified Version this is most probably 3.4.2, as I have the newer 4.2.0 I use this.

Mingw vista 01.pngMingw vista 02.png

Let's try to compile again and see the progress.

Compiler

Hm still doesn't work, but the error changed:

-------------- Build: Debug in test ---------------
Compiling: main.cpp
C:\Users\Christoph\Projects\test\main.cpp:1:20: error: iostream: No such file or directory
C:\Users\Christoph\Projects\test\main.cpp: In function 'int main()':
C:\Users\Christoph\Projects\test\main.cpp:7: error: 'cout' was not declared in this scope
C:\Users\Christoph\Projects\test\main.cpp:7: error: 'endl' was not declared in this scope
Process terminated with status 1 (0 minutes, 1 seconds)
3 errors, 0 warnings

So MinGW is not able to find <iostream>. Let's tell him where to search:

Still in the Compiler and Debugger dialogue go to "Search directories" -> "Compiler" and add:

C:\MinGW\include\c++\MinGW-Version
C:\MinGW\include\c++\MinGW-Version\backward
C:\MinGW\include\c++\MinGW-Version\mingw32
C:\MinGW\lib\gcc\mingw32\MinGW-Version\include

There are not necessarily all of them needed, but these are the directories MinGW searches on normally.

Try again to compile. The compiler should now execute nurmally, but there is a Linker error left:

Linker

Linking console executable: bin\Debug\test.exe
ld: cannot find -lgcc
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings

So we apparently need to tell MinGW where to search for it's librarys. This is again done by adding some "Search directories", but now we use the section "Linker"

C:\MinGW\lib\gcc\mingw32\MinGW-Version

Try to compile, it should work.

Mingw vista 03.pngMingw vista 04.png

Trouble shooting

If this does not work for you there are some advice to figure it out on your own:

  • If there is a file not found by MinGW use your search function to look for it, and add it where it belongs
    • If it's an executeable (.exe) add it to the "additional paths" under "toolchain executeables"
    • If it's a header (.h, .hpp or without extension) add it to "compiler" under "search directories"
    • If it's a library (.o, .a) add it to "linker" under "search directories"
  • Compile with the -v flag. You can do this by simply adding -v to "Build options" -> "Compiler" -> "Other options"