Difference between revisions of "MinGW installation"

From Code::Blocks
Line 77: Line 77:
  
 
===UnxUtils===
 
===UnxUtils===
 +
 
Ports of the most often used Unix utilities. Note that some tools in UnxUtils are quite a bit outdated, so make sure you <u>do not</u> overwrite already existing MinGW files with their UnxUtils counterparts.
 
Ports of the most often used Unix utilities. Note that some tools in UnxUtils are quite a bit outdated, so make sure you <u>do not</u> overwrite already existing MinGW files with their UnxUtils counterparts.
*[http://prdownloads.sf.net/unxutils/UnxUtils.zip UnxUtils]
+
 
*[http://prdownloads.sf.net/unxutils/UnxUpdates.zip UnxUtils-Latest-Updates]
+
* [https://sourceforge.net/projects/unxutils/ UnxUtils]
  
 
===GnuWin32===
 
===GnuWin32===
 +
 
*[https://sourceforge.net/projects/gnuwin32/ GnuWin32]
 
*[https://sourceforge.net/projects/gnuwin32/ GnuWin32]
 
*[ftp://ftp.info-zip.org/pub/infozip/win32/zip300xn.zip zip-3.0.0 32-bit] or [ftp://ftp.info-zip.org/pub/infozip/win32/zip300xn-x64.zip zip-3.0.0 64-bit]
 
*[ftp://ftp.info-zip.org/pub/infozip/win32/zip300xn.zip zip-3.0.0 32-bit] or [ftp://ftp.info-zip.org/pub/infozip/win32/zip300xn-x64.zip zip-3.0.0 64-bit]

Revision as of 03:25, 26 December 2015


Overview

A compiler suite is what Code::Blocks uses to turn the code you type into it into numbers that the computer understands. As a compiler is a very complex undertaking it is not part of Code::Blocks itself but rather is a separate project that Code::Blocks then uses. The specific compiler toolchain talked about in this page is a "MinGW" compiler. That means "Minimalist GCC for Windows." And "GCC" expands to "GNU Compiler Collection." There are many MinGW-based compiler suites, on this page we will concentrate on TDM-GCC.

GCC Compiler Toolchain Features

Various GCC compilers for Windows come with different features and which flavor of the compiler you end up choosing should reflect your specific needs.

Threads: Win32 / Posix

There are two major threading models to choose from:

  • win32 threads will not give you C++11 multithreading features.
  • posix threads enable C++11 multithreading features. It will make your resulting executable depend on your compiler's libwinpthreads included Dynamic Link Library. As a result you will have to distribute that library with your executable. If you want to use standard C++11 threading then choose posix.

Using one threading model or the other is not mutually exclusive, you can directly call each others API regardless of which model your compiler uses.

Exceptions: Dwarf / Long Jump Short Jump / Structured Exception Handling

There are three major exception models to choose from:

  • Dwarf exceptions are very fast, but if your exceptions have to pass through Windows APIs/code then you could have issues. If your project is basically self-contained and you do not expect to throw or catch exceptions through Windows APIs then it is a good 32-bit compiler choice. Dwarf exceptions are not available on 64-bit compilers.
  • LJSJ exceptions don't propagate through your code as fast as Dwarf exceptions but they can pass through Windows APIs/code. If you need your exceptions to pass through Windows code on a 32-bit system then LJSJ is a good choice.
  • SEH exceptions are very fast but only available on 64-bit compilers and not 32-bit ones because of a software patent. The software patent applies specifically to 32-bit compilers, not 64-bit ones, so SEH is only available royalty-free with a 64-bit compiler. SEH exceptions are both fast and can travel through Windows APIs/code. If you are developing with a 64-bit compiler then you should use SEH.

TDM-GCC

The fastest way to set up a working compiler is to install a recent GCC release targeting the MinGW compiler system from TDM-GCC. The Code::Blocks team recommends TDM builds of MinGW.

Installation

Download the on-demand installer and run it.

Go through the installation pages, the red arrows are all the default options which we will be keeping and the last blue arrow is to indicate that you will be putting TDM-GCC into your system's PATH. This is important because it means that during development the compiler libraries will be accessible by default to your programs as you develop them and also makes it easier to use utilities such as CMake as they will be able to find your compiler toolchain. When you actually distribute your programs to other computers then you will copy the needed Dynamic Link Libraries out of your TDM folder and include them as part of your installer. On your machine they are in your PATH so you always have them, on your users computers the won't have the compiler toolchain so there you provide the .dll files with your program.

TDM Create.png TDM Arch.png

TDM Inst Dir.png TDM Inst Options.png

Once you are ready, click Install to proceed.

Code::Blocks Configuration

Go to your Compiler settings:

Compiler Settings.png

And then under the "Toolchain executables" tab (red arrow), click on the ellipsis ("...", blue arrow) and choose the root directory where you installed TDM-GCC 32-bit. Once you have that directory chosen, in the "Program Files" sub-tab (green arrow) area fill out the fields as shown. If you choose the blue arrow ellipsis first then for each ellipsis you click on under "Program Files" you will already be in your TDM-GCC bin folder where the actual programs are.

CB TDM Toolchain.png

Now, go to your Debugger settings:

Settings Debugger.png

Choose your default debugger (red arrow), and then fill in the Executable path for it as shown for TDM-GCC 32-bit (blue arrow).

Debugger Default.png

Summary

You now have a Code::Blocks environment that is configured to use TDM-GCC 32-bit properly. Using this as a template you can easily set up alternative compilers no matter the source - just follow the same basic procedure.

Alternative MinGW Compilers

MinGW package From Equation

MinGW-Builds ➡ In, "Toolchains targeting Win32 or Win64," ➡ "Personal Builds," ➡ "mingw-builds," ➡ Version, ➡ Threading Model, ➡ Exception Model, ➡ Revision.

Mingw-w64 - the parent project of MinGW-Builds, includes much more than is necessary - MinGW-Builds will usually suffice instead of the full works.

Development Tools

Normally you should not need many of these listed tools. ZIP is convenient, especially when building Code::Blocks itself, but other than that these tools only serve specialized purposes.

UnxUtils

Ports of the most often used Unix utilities. Note that some tools in UnxUtils are quite a bit outdated, so make sure you do not overwrite already existing MinGW files with their UnxUtils counterparts.

GnuWin32