Difference between revisions of "MinGW installation"

From Code::Blocks
(Fix links to MinGW and TDM-GCC)
 
(56 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
[[Category:User Documentation]]
 
[[Category:User Documentation]]
  
== GCC Compiler Toolchain Features ==
+
== Overview ==
  
Various GCC compilers for Windows come with different features and which flavor of the compiler you end up choosing should reflect your specific needs.
+
A compiler toolchain is what Code::Blocks uses to turn the code you type into it into numbers that the computer understands.  As a compiler toolchain 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 kind of compiler toolchains talked about on this page are "MinGW" toolchains.  Which means "Minimalist GNU for Windows."  And "GNU" expands to "GNU's Not Unix."  More information about the GNU project can be found on the [https://www.gnu.org/home.en.html GNU Home Page].
  
=== Threads: Win32 / Posix ===
+
For most MinGW-based compiler toolchains, having your toolchain in your PATH is important because it means that during development the toolchain libraries will be accessible by default to your programs as you develop them and also makes it easier to use utilities such as [https://cmake.org/ CMake] as they will be able to find your compiler toolchainWhen you actually distribute your programs to other computers then you will copy the needed .dll files out of your toolchain directory and include them as part of your installerOn your machine they are in your PATH so you always have them, on your users computers they won't have the compiler toolchain so there you provide the .dll files with your program.
 
 
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 receive exceptions through Windows APIs then it is a good 32-bit compiler choice. Dwarf exceptions are not available on 64-bit compilers.
 
* LJSJ exceptions can travel through Windows APIs/code.  They don't propagate through your code as fast as Dwarf exceptions do but they have the ability to pass through Windows APIs/codeIf 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 patentThe 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 ==
 
== TDM-GCC ==
  
The fastest way to set up a working compiler is to install a recent GCC release targeting the MinGW compiler system from [http://tdm-gcc.tdragon.net/ TDM-GCC]. The Code::Blocks team recommends TDM builds of MinGW.
+
[https://jmeubank.github.io/tdm-gcc/ TDM-GCC] is the toolchain that will be used as the example for this guide.  TDM-GCC statically links the required toolchain libraries into your final executable.  Which means that when you create your installer for your final program there are less files to include - they are built into your executable itself. The Code::Blocks team recommends TDM-GCC.
  
 
=== Installation ===
 
=== Installation ===
Line 30: Line 15:
 
Download the on-demand installer and run it.
 
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 [https://cmake.org/ 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.
+
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.   
  
 
[[Image:TDM_Create.png]] [[Image:TDM_Arch.png]]
 
[[Image:TDM_Create.png]] [[Image:TDM_Arch.png]]
Line 44: Line 29:
 
[[Image:Compiler_Settings.png]]
 
[[Image: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 <tt>bin</tt> folder where the actual programs are.
+
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 aren't using the TDM-GCC toolchain there might be minor variation in the executable names.  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 <tt>bin</tt> directory where the actual programs are.
  
 
[[Image:CB_TDM_Toolchain.png]]
 
[[Image:CB_TDM_Toolchain.png]]
Line 58: Line 43:
 
=== Summary ===
 
=== 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.
+
You now have a Code::Blocks environment that is configured to use TDM-GCC 32-bit properly.  Using this guide as a template you can easily set up alternative compiler toolchains no matter the source - just follow the same basic procedure.
  
== Alternative MinGW GCC Compilers ==
+
== Alternative MinGW Compiler Toolchains ==
  
[http://www.equation.com/servlet/equation.cmd?fa=fortran MinGW package From Equation]
+
[https://osdn.net/projects/mingw/ MinGW] - The original project.
  
 
[https://sourceforge.net/projects/mingw-w64/files/ MinGW-Builds] ➡ In, "Toolchains targeting Win32 or Win64," ➡ "Personal Builds," ➡ "mingw-builds," ➡ Version, ➡ Threading Model, ➡ Exception Model, ➡ Revision.
 
[https://sourceforge.net/projects/mingw-w64/files/ MinGW-Builds] ➡ In, "Toolchains targeting Win32 or Win64," ➡ "Personal Builds," ➡ "mingw-builds," ➡ Version, ➡ Threading Model, ➡ Exception Model, ➡ Revision.
  
[http://mingw-w64.org/doku.php Mingw-w64] - the parent project of MinGW-Builds, includes much more than is necessary - MinGW-Builds will usually suffice instead of the full works.
+
[http://mingw-w64.org/doku.php Mingw-w64] - The parent project of MinGW-Builds, includes much more than is necessary - MinGW-Builds will usually suffice instead of the full works.
 +
 
 +
[http://www.equation.com/servlet/equation.cmd?fa=fortran MinGW Equation] - A package that also provides OpenMP.
  
 
==Development Tools==
 
==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.
+
Normally you should not need many of these tools.  ZIP is convenient, especially when: [[Installing_Code::Blocks_from_source_on_Windows | building Code::Blocks itself]], but other than that these tools only serve specialized purposes.
  
 
===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.
+
 
*[http://prdownloads.sf.net/unxutils/UnxUtils.zip UnxUtils]
+
* [https://sourceforge.net/projects/unxutils/ UnxUtils]
*[http://prdownloads.sf.net/unxutils/UnxUpdates.zip UnxUtils-Latest-Updates]
 
  
 
===GnuWin32===
 
===GnuWin32===
''More recent'' versions of commonly used Unix utilities. Also: utilities not found in UnxUtils at all.
+
 
*[http://prdownloads.sf.net/gnuwin32/coreutils-5.3.0-bin.zip coreutils-5.3.0]
+
*[https://sourceforge.net/projects/gnuwin32/ GnuWin32]
 +
 
 +
===ZIP===
 
*[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]
*[http://prdownloads.sf.net/gnuwin32/tar-1.13-1-bin.zip tar-1.13-1]
 
*[http://prdownloads.sf.net/gnuwin32/gzip-1.3.5-3-bin.zip gzip-1.3.5]
 
*[http://prdownloads.sf.net/gnuwin32/bzip2-1.0.3-1-bin.zip bzip2-1.0.0-1]
 
*[http://prdownloads.sf.net/gnuwin32/autoconf-2.59-bin.zip autoconf-2.59]
 
*[http://prdownloads.sf.net/gnuwin32/automake-1.9.4-bin.zip automake-1.9.4]
 
*[http://prdownloads.sf.net/gnuwin32/bison-2.1-bin.zip bison-2.1 (includes m4)]
 
*[http://prdownloads.sf.net/gnuwin32/flex-2.5.4a-1-bin.zip flex-2.5.4a]
 
*[http://prdownloads.sf.net/gnuwin32/gperf-3.0.1-bin.zip gperf-3.0.1]
 
*[http://prdownloads.sf.net/gnuwin32/diffutils-2.8.7-1-bin.zip diffutils-2.8.7]
 
*[http://prdownloads.sf.net/gnuwin32/patch-2.5.9-6-bin.zip patch-2.5.9-6] <br> Note: The version 2.5.9 of patch from GnuWin32 seems to have a problem with unified diffs
 
*[http://prdownloads.sf.net/gnuwin32/grep-2.5.1a-bin.zip grep-2.5.1]
 
*[http://prdownloads.sf.net/gnuwin32/sed-4.1.4-bin.zip sed-4.1.4]
 
*[http://prdownloads.sf.net/gnuwin32/hextools-1.0-bin.zip hextools-1.0]
 
*[http://prdownloads.sf.net/gnuwin32/findutils-4.2.20-2-bin.zip findutils-4.2.20]
 
*[http://prdownloads.sf.net/gnuwin32/less-394-bin.zip less 3.94]
 
*[http://prdownloads.sf.net/gnuwin32/which-2.16-4.exe which 2.16-4]
 
*[http://prdownloads.sf.net/mingw/wget-1.9.1-mingwPORT.tar.bz2 wget-1.9.1]
 
*[http://www.gimp.org/~tml/gimp/win32/gettext-0.14.5.zip gettext-0.14.5]
 
*[http://www.gimp.org/~tml/gimp/win32/gettext-dev-0.14.5.zip gettext-dev-0.14.5]
 
 
Dependencies:
 
*[http://prdownloads.sf.net/gnuwin32/pcre-6.4-1-bin.zip pcre-6.4.1 (needed by grep and less)]
 
*[http://prdownloads.sf.net/gnuwin32/libintl-0.14.4-bin.zip libintl-0.14.4 (needed by most tools)]
 
*[http://prdownloads.sf.net/gnuwin32/libiconv-1.9.2-1-bin.zip libiconv-1.9.2-1 (needed by most tools)]
 

Latest revision as of 13:30, 12 October 2024


Overview

A compiler toolchain is what Code::Blocks uses to turn the code you type into it into numbers that the computer understands. As a compiler toolchain 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 kind of compiler toolchains talked about on this page are "MinGW" toolchains. Which means "Minimalist GNU for Windows." And "GNU" expands to "GNU's Not Unix." More information about the GNU project can be found on the GNU Home Page.

For most MinGW-based compiler toolchains, having your toolchain in your PATH is important because it means that during development the toolchain 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 .dll files out of your toolchain directory 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 they won't have the compiler toolchain so there you provide the .dll files with your program.

TDM-GCC

TDM-GCC is the toolchain that will be used as the example for this guide. TDM-GCC statically links the required toolchain libraries into your final executable. Which means that when you create your installer for your final program there are less files to include - they are built into your executable itself. The Code::Blocks team recommends TDM-GCC.

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.

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 aren't using the TDM-GCC toolchain there might be minor variation in the executable names. 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 directory 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 guide as a template you can easily set up alternative compiler toolchains no matter the source - just follow the same basic procedure.

Alternative MinGW Compiler Toolchains

MinGW - The original project.

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.

MinGW Equation - A package that also provides OpenMP.

Development Tools

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

UnxUtils

GnuWin32

ZIP