Author Topic: Step by step guide to adding the TDM-GCC 64 bit compiler to Code::Blocks  (Read 14612 times)

Offline CJS

  • Multiple posting newcomer
  • *
  • Posts: 12
In 2015, Gabriel Aul, head of the Windows Insider Program, reported that "92.8% of systems with a BIOS age < 1yr are 64bit." AMD introduced 64-bit CPUs in 2003 and any PC with a 32-bit only processor would have to be at least 10 years old.  Clearly there's ample justification for any serious project to be able to build a 64 bit version.  Currently, Code::Blocks is primarily offered as an IDE which has the capability to support many compilers, at the user's choice, although the official release does install a MinGW compiler that generates 32 bit code from C/C++ code.

This account is based on my experience setting up Code::Blocks to create 64 bit builds for my latest project (a backup application: Link) - offered in support of anyone who is looking to add 64 bit capabilities to their own projects and might benefit from it.

To build 64-bit executables, you need a compiler that can generate 64-bit target executables (the compiler itself can run as a 32 bit or 64 bit executable).

Before you add a compiler, you might want to check that your default C++ compiler settings are up to date, for example if you want to build for the ISO C++ 2011 standard it would be a good idea to add the option "-std=gnu++11" or "-std=c++11" to the build options under Compiler settings / Other compiler options before you copy the compiler settings for your 64 bit version, and check other options such as build options/Number of processes for parallel builds to suit your computer.

This description is based on the TDM-GCC 64 bit compiler (MinGW64). TDM-GCC "combines the most recent stable release of the GCC toolset, a few patches for Windows-friendliness, and the free and open-source MinGW or MinGW-w64 runtime APIs..." (

It has been stated that the Code::Blocks team recommends TDM builds of MinGW (, and it's used for the nightly builds.

You will need to download and install the tdm64-gcc 64-bit compiler, and build the 64 bit libraries for wxWidgets if you use it (see references below).

To add the new compiler to your Code::Blocks setup, click on main menu Settings -> Compiler to open the Global compiler settings dialog.  Under Selected Compiler, select your existing built-in compiler i.e. "GNU GCC Compiler" (or the nearest equivalent if you are running a nightly build with a custom compiler), click Copy, then in the "Add new compiler" dialog enter the name for the new compiler, e.g. "tdm64-gcc 64-bit Compiler" and click OK.

With the new compiler selected, review the compiler settings.  You will need to update the toolchain for the compiler under the tab Toolchain executables. Modify the compilerís installation directory to the directory where you installed MinGW64, e.g. C:\tdm-gcc-64-5.1.0-2

Enter the following items, or click the Browse button [...] beside each Program Files option, and browse from the compilerís installation directory into the \bin folder, and select each item, as follows:

C compiler:          gcc.exe
C++ compiler:         g++.exe
Linker for dynamic libs:   g++.exe
Linker for static libs:    ar.exe
Debugger:         Set after configuring debugger - see below
Resource compiler:       windres.exe
Make program:       mingw32-make.exe

Next, set up the 64 bit debugger:

Click on main menu Settings -> Debugger..., select GDB/CDB debgger in the tree on the left, underneath which you should see the Default setting for the existing 32 bit debugger, and then click the Create Config button. In the popup window, enter the name for the new configuration - e.g. gdb64.

Under Executable path, select the corresponding gdb debugger for mingw64, e.g. C:\tdm-gcc-64-5.1.0-2\bin\gdb64.exe.  Other settings (Debugger Type: GDB, etc.) can stay the same as for the Default configuration (unless you have some specific requirement, and you can always change them later).

Now go back to the Settings -> Compiler dialog, select the new compiler under "Selected compiler", select the Toolchain executables and Program Files tabs, and change the Debugger selection to the new configuration e.g. "GDB/CDB Debugger : gdb64".

This new compiler setup can now be used in any new or existing projects.  You can specify the new compiler during creation of a project in the new project wizard, but if you want both 32 bit and 64 bit builds with different compilers it might be better to start by specifying the default 32 bit compiler and adding the extra 64 bit builds to your project afterwards.

To add a 64 bit build to your existing project using your new compiler setup, it's most convenient to start from working 32-bit targets to base them on (e.g. commonly Debug and Release). Right-click on the project in the Projects tab of the Manager tree, select Properties to open the Project/targets options dialog, then select the Build targets tab, and for each existing target listed on the left column, select it and click the Duplicate button - give the new targets suitable names, e.g. Debug64 and Release64.

For each new target, rename the "Objects output dir" to point to a different subdirectory, e.g. obj\Debug64\ (Code::Blocks will create this directory in the build, so you won't necessarily be able to browse to it). Also change the output filename to point to a matching new objects output directory, e.g. bin\Debug64\<appname>.exe. If you created a new project for 64 bit builds only, specifying the new 64 bit compiler, you don't have to change these, just use the default obj\Debug and obj\Release.

Select the Project settings tab of the Project/targets options dialog, and click the "Project's build options" button.
Select the new target, and change the compiler to the 64-bit compiler e.g. "tdm64-gcc 64-bit Compiler".
Select the Search directories tab, and change the directory or directories to point to the 64-bit version, repeating this for each sub-tab under the Search directories tab, e.g. for a debug target:

Compiler: C:\wxWidgets-3.0.2\lib\gcc_lib\mswud changes to C:\wxWidgets-3.0.2\lib\gcc_lib64\mswud

Linker: C:\wxWidgets-3.0.2\lib\gcc_lib changes to C:\wxWidgets-3.0.2\lib\gcc_lib64

Resource compiler: C:\wxWidgets-3.0.2\lib\gcc_lib\mswud changes to C:\wxWidgets-3.0.2\lib\gcc_lib64\mswud

Save the project. You should now be able to build 32-bit Debug and Release targets, and 64 bit Debug64 and Release64 targets, by just selecting the appropriate target and building.


Installing a supported compiler

MinGW installation

Setting up Code::Blocks for use with MinGW-64 [2014]

Building 32 bit and 64 bit wxWidgets libraries for use with Code::Blocks 16.01