Difference between revisions of "Installing MinGW with Vista"
Line 85: | Line 85: | ||
** If it's a library (.o, .a) add it to "linker" 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" | * Compile with the -v flag. You can do this by simply adding -v to "Build options" -> "Compiler" -> "Other options" | ||
− | * Try entering the complete path to each program (for example, changing "mingw32-g++.exe" to "D:\toolkits\MinGW513\bin\mingw32-g++.exe"). This may allow projects to be compiled, | + | * Try entering the complete path to each program (for example, changing "mingw32-g++.exe" to "D:\toolkits\MinGW513\bin\mingw32-g++.exe"). This may allow projects to be compiled, regardless of which partition and folder MinGW is installed to. |
Revision as of 21:48, 13 July 2007
--Darthdespotism 07:23, 29 June 2007 (UTC)
Before we start
Before 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 must 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 it is most probably 3.4.2
Just one thing left: I've done this under Vista Business and a friend of mine reported it working with Home Premium. I hope it works on the other versions, too.
Getting MinGW
First of all you need the MinGW Compiler to be 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.* though. 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% - variables 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 "console application" 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 doesn't tell us very much. 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.
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 in 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.
Trouble shooting
If this does not work out for you there is 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"
- Try entering the complete path to each program (for example, changing "mingw32-g++.exe" to "D:\toolkits\MinGW513\bin\mingw32-g++.exe"). This may allow projects to be compiled, regardless of which partition and folder MinGW is installed to.