Installing a supported compiler
When you launch Code::Blocks for the first time, it will scan the system for any supported compilers. Once this scan has finished, Code::Blocks will have been correctly configured for any detected compilers. Code::Blocks will also have default configurations even for compilers that were not found.
This article is a guide for obtaining, installing, and configuring the various compilers that Code::Blocks can use.
- 1 Windows
- 2 Linux
- 3 Mac OS X
- 4 Compiler-neutral setup steps
- 5 Remote Compilation
- 6 Misc. Custom Compilers
Once you've installed a new compiler, be sure to read the Compiler-neutral setup steps at the end of this article.
At the time of this writing, Code::Blocks supports the following compilers in Windows:
- MinGW GCC C/C++ Free Compiler, including G77 (Fortran)
- Cygwin GCC C/C++ Free Compiler
- HOWTO: Use Cygwin 1.7 with Code::Blocks
- Cygwin GCC C/C++ Free Compiler
- MSP430 GCC C/C++
- TriCore GCC C/C++
- PowerPC GCC C/C++
- Microsoft's Visual C++ Free Toolkit 2003
- Borland's C/C++ Free Compiler 5.5
- Digital Mars Free C/C++ Compiler
- OpenWatcom Free C/C++ Compiler
- Small Device Free C Compiler (SDCC)
- Intel C/C++ Compiler
The official MinGW website is at mingw.org. A MinGW-bundled version of the latest Code::Blocks release is available from the Code::Blocks download page. If you install this version, the GCC compiler will be automatically detected and set as the default. Also you can use the TDM's GCC/mingw32 Builds from  or .
Note: In any case, if you don't install MinGW in C:\MinGW, you'll need to update the configuration of GCC in Code::Blocks.
Packages required (suggested) for MinGW/GCC v3.4.5:
Packages required (suggested) for MinGW/GCC v4.4.0:
HOWTO: Use Cygwin 1.7 with Code::Blocks
Cygwin 1.7 changed the way symlinks were created and handled when invoked from a command prompt. I couldn't find a way to force CB to use a unix-link shell, but was able to find a work around when perusing the Cygwin mailing lists.
The symptom would show up with a message similar to the one below:
Execution of 'g++.exe -Wall -fexceptions -g -c c:/dev/code/cb1/main.cpp -o obj/Debug/main.o' in 'c:\dev\code\cb1' failed.
Executing the same command from the CMD.EXE prompt yields an "Access is denied" message. This was how I was able to track down why the issue occurred. For more info, see this cygwin mailing list thread: http://www.mail-archive.com/[email protected]/msg104088.html
The solution is to point your compiler and linker directly to the version of gcc and g++ that you want to use.
In my case, I wanted to use gcc-4.exe and g++-4.exe and so, I went into Settings->Compiler and Debugger->Toolchain executables. There I changed the "C Complier", "C++ Compiler" and "Linker for dynamic libs" to point to gcc-4.exe, g++-4.exe and g++-4.exe.
After this, compilation and linking worked fine.
It would also be a good idea to add an environment variable CYGWIN with a value of nodosfilewarning in Settings->Environment->Environment Variables. This eliminates the following (harmless) warning message:
MS-DOS style path detected: c:/ Preferred POSIX equivalent is: /c CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
(Unofficial) TDM - "Twilight Dragon Media"
Packages required (suggested) for TDM's GCC/mingw32 Builds v4.4.1-tdm-2 SJLJ: ...which can be found here:  under: TDM-GCC 4.4 series -> 4.4.1-tdm-2 SJLJ.
Microsoft Visual C++
The official Visual C++ website is at http://msdn.microsoft.com/en-us/visualc/default.aspx.
Code::Blocks will work with any edition of Visual C++ since the 2003 edition (MSVC 7.1). The commercial editions of Visual Studio may require additional configuration in Code::Blocks to work correctly. You can also download the most recent "Express" edition of Visual C++ for free from microsoft.com/express/vc. If you choose an "Express" edition of Visual C++, it is highly recommended that you also install Microsoft's Platform SDK in order to develop programs for Windows.
Borland C++ Compiler 5.5
NOTE: At some point, you will be asked to register with Borland and fill out a survey. Registration is free.
Go to Borland's downloads and click on the link labeled "Compiler". After you accept the license agreement, you will be provided with download links to the setup file.
Digital Mars C/C++ Free Compiler
Go to DigitalMars. Accept the license agreement and you'll be redirected to a page containing download links.
In that page, download:
- The Digital Mars C/C++ Compiler (dm8**c.zip)
- The Basic Utilities (bup.zip)
- The STLport library (stlport.zip)
Open dm\bin\sc.ini in a text editor, and replace the line
Intel C++ Compiler
Please note that on Windows platform, Intel C/C++ compiler requires Microsoft Visual C++ to be present in your system in order to function properly. It will not compile any C++ program without it. You should also note that Windows SDK shall be installed in order to compile Windows app.
Code::Blocks (C::B) is now able to detect (from svn revision 4967 onwards) Intel C/C++ compiler and it'll then automatically setup the MSVC compiler so that the Intel compiler works as intended. However if you wish to manually install the Intel C/C++ compiler, then follow the following steps.
- Go to Settings > Compilers and debuggers and then select Intel C/C++ compiler.
- Click on the Toolchain executables tab. Point to the installation directory, e.g. C:\Program Files\Intel\Compiler\C++\10.1.020\IA32 , inside the Compiler's installation directory textbox.
- Click on the Additional Paths tab and fill in the directories pointing to MSVC bin directory and the Windows SDK directory. It may look like-
C:\Program Files\Microsoft Visual Studio 8\VC\bin C:\Program Files\Microsoft Visual Studio 8\Common7\IDE C:\Program Files\Microsoft SDKs\Windows\v6.0\bin
- Click on the Search directories tab and add the include directories containing headers offered by Intel C/C++ compiler, MSVC compiler and the Windows SDK headers to Compiler and Resource compiler. It may look like-
C:\Program Files\Intel\Compiler\C++\10.1.020\IA32\include C:\Program Files\Microsoft Visual Studio 8\VC\include C:\Program Files\Microsoft SDKs\Windows\v6.0\Include
- Click on the Linker tab under Search directories tab and add the directories containing libraries offered by Intel C/C++ compiler, MSVC compiler and the Windows SDK. It may look like-
C:\Program Files\Intel\Compiler\C++\10.1.020\IA32\lib C:\Program Files\Microsoft Visual Studio 8\VC\lib C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib
Click on the OK button to save the settings. Now you should be able to use Intel C/C++ compilers on Windows with C::B.
Note: The directories specified above may be different on your PC.
At the time of this writing, Code::Blocks supports the following compilers in Linux:
Downloading the GNU GCC compiler & GDB debugger
Under Linux you'll, most probably, already have everything that is needed in order to compile. All major Linux distributions (RedHat, Debian, SuSE, Mandriva, Gentoo, ArchLinux, etc) come with GCC & GDB preinstalled. To make sure you have have gcc installed, go to your terminal and type 'gcc -v'. In case you have GCC installed, you will get GCC's compile options and version number.
Mac OS X
The Mac OS X port efforts has began recently, but it should be a matter of time until these compilers will be supported:
Downloading the GNU GCC compiler & GDB debugger
Under Mac you'll need to install Xcode Tools from http://developer.apple.com/tools/
This will install Apple versions of:
Compiler-neutral setup steps
Now that you have downloaded the setup file of the compiler of your choice, launch its installation by double-clicking on the setup file. The actual installation process is really simple. Just press "Next" all the way and you 're done.
If you installed the compiler on its default installation directory, there is nothing more to configure. Launch Code::Blocks and you 're all set :)
If that is not the case, launch Code::Blocks. If it is the first time you launch it, the compiler auto-detection will be launched. If your compiler was not auto-detected, go to "Settings->Compiler and Debugger->Global Compiler settings->Toolchain executables", select the compiler you installed and press "Auto-detect". If you get a message saying that the compiler was auto-detected, congratulations! If not, then press the button with the three dots next to the "Auto-detect" button and select the installation directory of your compiler manually.
NOTE: The compiler's installation directory is exactly this: the installation directory. Not the "bin" subdirectory nor any other.
Remote compilation is not directly supported by Code::Blocks, however, the following articles explain two remote compilation systems, which use 3rd party programs to provide this funcionality:
Misc. Custom Compilers
There are several user contributions for different (non-C/C++) compiler which are listed here: