Difference between revisions of "Installing a supported compiler"

From Code::Blocks
m (→‎MinGW/GCC: Make link to forum absolute)
 
(62 intermediate revisions by 7 users not shown)
Line 4: Line 4:
 
This article is a guide for obtaining, installing, and configuring the various compilers that Code::Blocks can use.
 
This article is a guide for obtaining, installing, and configuring the various compilers that Code::Blocks can use.
  
 +
 +
== Compiler-neutral setup steps ==
 +
 +
Before using a compiler with Code::Blocks you have to install it. The method for installing the compiler depends on the Operating system you're using, the Compiler you intend to use and so on.
 +
If you installed the compiler on its default installation directory, there is nothing more to configure (if the compiler is natively supported by Code::Blocks). 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.''
  
 
== Windows ==
 
== Windows ==
Line 10: Line 23:
  
 
At the time of this writing, Code::Blocks supports the following compilers in Windows:
 
At the time of this writing, Code::Blocks supports the following compilers in Windows:
* [http://www.mingw.org MinGW GCC C/C++ Free Compiler, including G77 (Fortran)]
+
* [http://www.mingw.org MinGW GCC C/C++ Free Compiler, including GFortran]
 
** [http://www.cygwin.org Cygwin GCC C/C++ Free Compiler]
 
** [http://www.cygwin.org Cygwin GCC C/C++ Free Compiler]
*** HOWTO: Use Cygwin 1.7 with Code::Blocks  
+
*** [[#HOWTO: Use Cygwin 1.7 with Code::Blocks|HOWTO: Use Cygwin 1.7 with Code::Blocks]]
* [http://mspgcc.sourceforge.net/ MSP430 GCC C/C++]
+
* [http://www.ti.com/tool/msp430-gcc-opensource MSP430 GCC C/C++]
* [http://www.hightec-rt.com/ TriCore GCC C/C++]
+
* [http://www.hightec-rt.com/en/downloads/evaluation-version.html TriCore GCC C/C++]
* [http://www.hightec-rt.com/ PowerPC GCC C/C++]
+
* [http://www.hightec-rt.com/en/downloads/evaluation-version.html PowerPC GCC C/C++]
* [http://msdn.microsoft.com/visualc/vctoolkit2003 Microsoft's Visual C++ Free Toolkit 2003]
+
* [http://sdcc.sourceforge.net/ Small Device Free C Compiler (SDCC)]
* [http://www.borland.com/products/downloads/download_cbuilder.html Borland's C/C++ Free Compiler 5.5]
 
 
* [http://www.digitalmars.com/ Digital Mars Free C/C++ Compiler]
 
* [http://www.digitalmars.com/ Digital Mars Free C/C++ Compiler]
* [http://store.scitechsoft.com/product_info.php?products_id=37/ OpenWatcom Free C/C++ Compiler]
+
* [http://www.digitalmars.com/d/2.0/dmd-windows.html Digital Mars D Compiler for Windows]
* [http://sdcc.sourceforge.net/ Small Device Free C Compiler (SDCC)]
+
These compilers are generally still under active development by their publishers, so a new version of their software could be released that is incompatible with the current version of Code::Blocks.
* [http://www.intel.com/cd/software/products/asmo-na/eng/compilers/index.htm Intel C/C++ Compiler]
+
 
 +
The following compilers are still supported by Code::Blocks, but are no longer available from their original publishers.
 +
* Microsoft's Visual C++ 2003 - 2010
 +
* Borland's C/C++ Free Compiler 5.5
 +
 
 +
The following publishers have released newer versions of their compilers which should be tested against the current configuration.  In other words, it is not known yet whether these compilers still work with Code::Blocks.
 +
<!-- * [https://www.embarcadero.com/free-tools/ccompiler Embarcadero's (formerly Borland) C/C++ Free Compiler] -->
 +
* [http://www.openwatcom.org/download.php OpenWatcom Free C/C++ Compiler]
 +
* [https://software.intel.com/en-us/c-compilers/ipsxe Intel C/C++ Compiler] <!-- Does somebody have this one? I do not quality for the free version and do not need to pay for yet another C-compiler on my machine. -->
  
 
=== MinGW/GCC ===
 
=== MinGW/GCC ===
The official MinGW website is at [http://www.mingw.org mingw.org]. A MinGW-bundled version of the latest Code::Blocks release is available from the [https://www.codeblocks.org/downloads/5#windows 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 [/index.php/topic,10508.0.html] or [http://www.tdragon.net/recentgcc/].
+
The official MinGW website is at [http://www.mingw.org mingw.org]. A MinGW-bundled version of the latest Code::Blocks release is available from the [https://www.codeblocks.org/downloads/5#windows 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 [https://forums.codeblocks.org/index.php/topic,10508.0.html] or [http://www.tdragon.net/recentgcc/].
  
 
'''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.
 
'''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.
Line 64: Line 84:
 
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/cygwin@cygwin.com/msg104088.html
 
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/cygwin@cygwin.com/msg104088.html
  
'''[[Solution]]'''
+
'''Solution'''
  
 
The solution is to point your compiler and linker directly to the version of gcc and g++ that you want to use.
 
The solution is to point your compiler and linker directly to the version of gcc and g++ that you want to use.
Line 79: Line 99:
 
     Consult the user's guide for more details about POSIX paths:
 
     Consult the user's guide for more details about POSIX paths:
 
       http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
 
       http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
 +
 +
See also: [[Installing Cygwin Compiler]]
  
 
==== (Unofficial) TDM - "Twilight Dragon Media" ====
 
==== (Unofficial) TDM - "Twilight Dragon Media" ====
Line 97: Line 119:
 
These packages are included in both the [http://sourceforge.net/projects/tdm-gcc/files/TDM-MinGW%20Installer/1.908.0/tdm-mingw-1.908.0-4.4.1-2.exe/download Bundled Installer] and the [http://sourceforge.net/projects/tdm-gcc/files/TDM-MinGW%20Installer/1.908.0/tdm-mingw-1.908.0-webdl.exe/download On-Demand Installer] available via TDMs page referenced above for users who do not wish to download and install them manually.
 
These packages are included in both the [http://sourceforge.net/projects/tdm-gcc/files/TDM-MinGW%20Installer/1.908.0/tdm-mingw-1.908.0-4.4.1-2.exe/download Bundled Installer] and the [http://sourceforge.net/projects/tdm-gcc/files/TDM-MinGW%20Installer/1.908.0/tdm-mingw-1.908.0-webdl.exe/download On-Demand Installer] available via TDMs page referenced above for users who do not wish to download and install them manually.
  
=== Microsoft Visual C++ ===
+
=== Embarcadero C++ Compiler BCC32C ===
The official Visual C++ website is at [http://msdn.microsoft.com/en-us/visualc/default.aspx http://msdn.microsoft.com/en-us/visualc/default.aspx].
+
Formerly Borland's C++ Compiler, this compiler is now published by Embarcadero, with active on-going development; the current version is 10.1 as of this writing. Go to [https://www.embarcadero.com/free-tools/ccompiler their product download page] to download. You will be asked to enter some registration information (registration is free) then the download will begin. You will receive a ZIP archive which contains installation instructions in a text file in the root directory of the archive; it does not have an installer program.
 
 
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 [http://www.microsoft.com/express/vc/ 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 [http://www.borland.com/products/downloads/download_cbuilder.html# 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 ===
 
=== Digital Mars C/C++ Free Compiler ===
Line 143: Line 158:
  
 
Note: The directories specified above may be different on your PC.
 
Note: The directories specified above may be different on your PC.
 +
 +
=== Digital Mars D Compiler for Windows ===
 +
Now Digital Mars D Compiler (DMD) supports 32bit Windows, and in future it will support 64bit Windows.
 +
If you want to build D program in CodeBlocks on 32bit Windows, please following the instructions as bellow.
 +
 +
1). Install DMD(2.0) into your Windows system.
 +
 +
You should correctly combine the DMD compiler and install it into your system. Please view the instructions on digitalmars.com website.
 +
DMD for Windows http://www.digitalmars.com/d/2.0/dmd-windows.html
 +
 +
The newest DMD2 source you can get here: https://github.com/D-Programming-Language
 +
 +
 +
2). Settings in CodeBlocks.
 +
 +
You should add correct DMD pathes into CodeBlocks '''Global compiler settings'''
 +
 +
    2.1). "Settings -> Compiler and debugger settings" and choose compiler to "'''Digital Mars D Compiler'''";
 +
    2.2). click "Compiler settings -> Other options", add  '''-m32'''  into the field;
 +
    2.3). click "Linker settings", and add "'''D:\Program\DMD2\windows\lib\phobos.lib'''" into the "Link libraries";
 +
    2.4). click "Search directories -> Compiler", and add "'''D:\Program\DMD2\src\phobos'''" into the field;
 +
    2.5). click "Search directories -> Linker", and add "'''D:\Program\DMD2\windows\lib'''" into the field;
 +
    2.6). click "Toolchain executables", add "'''D:\Program\DMD2\windows'''" into the "Compiler's installation directory" filed;
 +
          (if you installed DMD2 correctly acc. to Installation setp, just click 'Auto-detect' button.)
 +
    2.7). Additional: If you wan to specify the DMC (Digital Mars C/C++ Compiler) you can do like this:
 +
          click "Toolchain executables -> Additional Paths", and add "D:\Program\DMC\bin" into the field.
 +
 +
The "D:\Program\DMD2" or "D:\Program\DMC\bin" here should change to your own DMD or DMC path in your system.
 +
 +
 +
3). Testing D program in CodeBlocks.
 +
 +
In CodeBlocks, produce a '''D Application''' project, and input your own D code into the .d file in the project, then '''build/run'''.
  
 
== Linux ==
 
== Linux ==
Line 150: Line 198:
 
* [http://sdcc.sourceforge.net/ Small Device Free C Compiler (SDCC)]
 
* [http://sdcc.sourceforge.net/ Small Device Free C Compiler (SDCC)]
 
* [http://www.intel.com/cd/software/products/asmo-na/eng/compilers/index.htm Intel C/C++ Compiler]
 
* [http://www.intel.com/cd/software/products/asmo-na/eng/compilers/index.htm Intel C/C++ Compiler]
 +
* [http://www.digitalmars.com/d/2.0/dmd-linux.html Digital Mars D Compiler for Linux]
 +
 +
===Digital Mars D Compiler for Linux===
 +
Now Digital Mars D Compiler (DMD) supports 32bit and 64bit Linux, and 'support Linux library' is under construction. If you want to build D program in CodeBlocks on 32bit and 64bit Linux, please following the instructions as bellow.
 +
 +
1). Install DMD(2.0) into your Linux system.
 +
 +
You should correctly combine the DMD compiler and install it into your system. Please view the instructions on digitalmars.com website.
 +
DMD for Linux http://www.digitalmars.com/d/2.0/dmd-linux.html
 +
 +
The newest DMD2 source you can get here:
 +
https://github.com/D-Programming-Language
 +
 +
 +
2). Settings in CodeBlocks.
 +
 +
A). 32bit Linux & 32bit DMD2.
 +
 +
On 32bit Linux, you should combine 32bit DMD2 from DMD2 source and install it into your system.
 +
 +
You should add correct DMD pathes into CodeBlocks '''Global compiler settings'''.
 +
 +
    A.1). "Settings -> Compiler and debugger settings" and choose compiler to "'''Digital Mars D Compiler'''";
 +
    A.2). click "Compiler settings -> Other options", add  '''-m32'''  into the field.
 +
    A.3). click "Linker settings", and add "'''/opt/dmd2/linux/lib32/libphobos2.a'''" into the "Link libraries".
 +
    A.4). click "Search directories -> Compiler", and add "'''/opt/dmd2/src/phobos'''" into the field.
 +
    A.5). click "Search directories -> Linker", and add "'''/opt/dmd2/linux/lib32'''" into the field.
 +
    A.6). click "Toolchain executables", add "'''/opt/dmd2/linux'''" into the "Compiler's installation directory" filed.
 +
    A.7). change the value of "Program Files -> Linker for dynamic libs" to "'''gcc -m32 -lrt'''" or "'''gcc -lrt'''".
 +
 +
If you installed DMD2 to a different path, please modify "/opt/dmd2" to your own DMD2 path.
 +
 +
 +
B1). 64bit Linux & '''64bit DMD2'''.
 +
 +
On 64bit Linux, you can combine 64bit DMD2 from DMD2 source and install it into your system.
 +
 +
You should add correct DMD paths into CodeBlocks '''Global compiler settings'''.
 +
 +
    B1.1). "Settings -> Compiler and debugger settings" and choose compiler to "'''Digital Mars D Compiler'''";
 +
    B1.2). click "Compiler settings -> Other options", add  '''-m64'''  into the field.
 +
    B1.3). click "Linker settings", and add "'''/opt/dmd2/linux/lib64/libphobos2.a'''" into the "Link libraries".
 +
    B1.4). click "Search directories -> Compiler", and add "'''/opt/dmd2/src/phobos'''" into the field.
 +
    B1.5). click "Search directories -> Linker", and add "'''/opt/dmd2/linux/lib64'''" into the field.
 +
    B1.6). click "Toolchain executables", add "'''/opt/dmd2/linux'''" into the "Compiler's installation directory" filed.
 +
    B1.7). change the value of "Program Files -> Linker for dynamic libs" to "'''gcc -m64 -lrt'''" or "'''gcc -lrt'''".
 +
 +
If you installed DMD2 to a different path, please modify "/opt/dmd2" to your own DMD2 path.
 +
 +
 +
B2). 64bit Linux with '''32bit DMD2'''.
 +
 +
On 64bit Linux, you can combine 32bit DMD2 with 64bit together from DMD2 source and install them into your system.
 +
 +
You should add correct DMD paths into CodeBlocks '''Global compiler settings'''.
 +
 +
    B2.1). "Settings -> Compiler and debugger settings" and choose compiler to "'''Digital Mars D Compiler'''";
 +
    B2.2). click "Compiler settings -> Other options", add '''-m32''' into the field.
 +
    B2.3). click "Linker settings", and add "'''/opt/dmd2/linux/lib32/libphobos2.a'''" into the "Link libraries".
 +
    B2.4). click "Search directories -> Compiler", and add "'''/opt/dmd2/src/phobos'''" into the field.
 +
    B2.5). click "Search directories -> Linker", and add "'''/opt/dmd2/linux/lib32'''" into the field.
 +
    B2.6). click "Toolchain executables", add "'''/opt/dmd2/linux'''" into the "Compiler's installation directory" filed.
 +
    B2.7). change the value of "Program Files -> Linker for dynamic libs" to "'''gcc -m32 -lrt'''".
 +
 +
If you installed DMD2 to a different path, please modify "/opt/dmd2" to your own DMD2 path.
 +
 +
 +
3). Testing D program in CodeBlocks.
 +
 +
In CodeBlocks, produce a '''D Application''' project, and input your own D code into the .d file in the project, then '''build/run'''.
  
 
=== Downloading the GNU GCC compiler & GDB debugger ===
 
=== 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.
 
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==
 
==Mac OS X==
Line 164: Line 281:
 
=== Downloading the GNU GCC compiler & GDB debugger ===
 
=== Downloading the GNU GCC compiler & GDB debugger ===
  
Under Mac you'll need to install Xcode Tools from http://developer.apple.com/tools/
+
Under Mac you'll need to install a ''compatible'' version Xcode Tools from http://developer.apple.com/tools/ (or http://developer.apple.com/downloads). You need the "Command Line Tools".
  
 
This will install Apple versions of:
 
This will install Apple versions of:
  
 
http://www.gnu.org/software/gcc/
 
http://www.gnu.org/software/gcc/
 +
 
http://www.gnu.org/software/gdb/
 
http://www.gnu.org/software/gdb/
 +
 
http://www.gnu.org/software/make/
 
http://www.gnu.org/software/make/
  
 +
=== Setting up compiler switches ===
 +
 +
Usually you need to tweak the compiler options to be able to compile C++ applications - that's the stuff Xcode hides from your eyes, but you better should know. You need to point to the GNU compiler's C/C++ include folders, to the GNU linkers libraries folder and a adjust the compiler options to setup the GNU compiler root path. Those path's differ depending on what hardware (processor architecture) and what version of MacOS is used. For an Intel based Mac with MacOS 10.6.2 and Xcode v3.2.2 the following should work:
 +
 +
Compiler search directories ("include" folders):
 +
 +
<code>
 +
/Developer/SDKs/MacOSX10.6.sdk/usr/include
 +
</code>
 +
 +
<code>
 +
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1
 +
</code>
  
== Compiler-neutral setup steps ==
+
Linker search directories ("library" folders):
  
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.
+
<code>
 +
/Developer/SDKs/MacOSX10.6.sdk/usr/lib
 +
</code>
  
If you installed the compiler on its default installation directory, there is nothing more to configure. Launch Code::Blocks and you 're all set :)
+
<code>
 +
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1
 +
</code>
  
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.
+
Additional compiler flags:
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.''
+
<code>
 +
-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -gdwarf-2
 +
</code>
  
 
== Remote Compilation ==
 
== Remote Compilation ==
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:
+
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 functionality:
  
 
[[Installing Uniwin remote compiler]]<br />
 
[[Installing Uniwin remote compiler]]<br />
Line 193: Line 328:
  
 
== Misc. Custom Compilers ==
 
== Misc. Custom Compilers ==
There are several user contributions for different (non-C/C++) compiler which are listed as following:
+
There are several user contributions for different (non-C/C++) compiler which are listed here:
 
 
[[Installing Objective-C Compiler]]
 
  
[[Using the Code::Blocks IDE with SDCC on PIC MCUs]]
+
https://wiki.codeblocks.org/index.php?title=User_documentation#Compilers

Latest revision as of 06:52, 17 November 2022

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.


Compiler-neutral setup steps

Before using a compiler with Code::Blocks you have to install it. The method for installing the compiler depends on the Operating system you're using, the Compiler you intend to use and so on. If you installed the compiler on its default installation directory, there is nothing more to configure (if the compiler is natively supported by Code::Blocks). 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.

Windows

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:

These compilers are generally still under active development by their publishers, so a new version of their software could be released that is incompatible with the current version of Code::Blocks.

The following compilers are still supported by Code::Blocks, but are no longer available from their original publishers.

  • Microsoft's Visual C++ 2003 - 2010
  • Borland's C/C++ Free Compiler 5.5

The following publishers have released newer versions of their compilers which should be tested against the current configuration. In other words, it is not known yet whether these compilers still work with Code::Blocks.

MinGW/GCC

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 [1] or [2].

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.

Official MinGW.org

You can install MinGW yourself, by using an automatic downloader/installer or by downloading and unpacking the required packages by hand from mingw.org, here: [3].

Packages required (suggested) for MinGW/GCC v3.4.5:

  • Compiler:
    • gcc-build-3.4.5-20060117-3.tar.gz
    • gcc-core-3.4.5-20060117-3.tar.gz
    • gcc-g++-3.4.5-20060117-3.tar.gz
  • Components:
    • binutils-2.19.1-mingw32-bin.tar.gz
    • gdb-6.8-mingw-3.tar.bz2
    • mingw32-make-3.81-20080326.tar.gz
    • mingwrt-3.16-mingw32-dev.tar.gz
    • mingwrt-3.16-mingw32-dll.tar.gz
    • w32api-3.13-mingw32-dev.tar.gz

Packages required (suggested) for MinGW/GCC v4.4.0:

  • Compiler:
    • gcc-full-4.4.0-mingw32-bin-2.tar.lzma
  • Components:
    • binutils-2.19.1-mingw32-bin.tar.gz
    • gdb-6.8-mingw-3.tar.bz2
    • mingw32-make-3.81-20080326.tar.gz
    • mingwrt-3.16-mingw32-dev.tar.gz
    • mingwrt-3.16-mingw32-dll.tar.gz
    • w32api-3.13-mingw32-dev.tar.gz

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/cygwin@cygwin.com/msg104088.html

Solution

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

See also: Installing Cygwin Compiler

(Unofficial) TDM - "Twilight Dragon Media"

These packages are called TDM's GCC/mingw32 Builds and can be obtained from [/index.php/topic,10508.0.html] or [4].

Packages required (suggested) for TDM's GCC/mingw32 Builds v4.4.1-tdm-2 SJLJ: ...which can be found here: [5] under: TDM-GCC 4.4 series -> 4.4.1-tdm-2 SJLJ.

  • Compiler:
    • gcc-4.4.1-tdm-2-core.zip
    • gcc-4.4.1-tdm-2-g++.zip
  • Components:
    • binutils-2.19.1-mingw32-bin.tar.gz
    • gdb-6.8-mingw-3.tar.bz2
    • mingw32-make-3.81-20080326-3.tar.gz
    • mingwrt-3.16-mingw32-dev.tar.gz
    • mingwrt-3.16-mingw32-dll.tar.gz
    • w32api-3.13-mingw32-dev.tar.gz

These packages are included in both the Bundled Installer and the On-Demand Installer available via TDMs page referenced above for users who do not wish to download and install them manually.

Embarcadero C++ Compiler BCC32C

Formerly Borland's C++ Compiler, this compiler is now published by Embarcadero, with active on-going development; the current version is 10.1 as of this writing. Go to their product download page to download. You will be asked to enter some registration information (registration is free) then the download will begin. You will receive a ZIP archive which contains installation instructions in a text file in the root directory of the archive; it does not have an installer program.

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

INCLUDE="%@P%\..\include";"%@P%\..\mfc\include";%INCLUDE%

with

INCLUDE="%@P%\..\stlport\stlport";"%@P%\..\include";"%@P%\..\mfc\include";%INCLUDE%

Intel C++ Compiler

Please note that on Windows platform, Intel C/C++ compiler requires Microsoft Visual C++[6] 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[7] 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.

Digital Mars D Compiler for Windows

Now Digital Mars D Compiler (DMD) supports 32bit Windows, and in future it will support 64bit Windows. If you want to build D program in CodeBlocks on 32bit Windows, please following the instructions as bellow.

1). Install DMD(2.0) into your Windows system.

You should correctly combine the DMD compiler and install it into your system. Please view the instructions on digitalmars.com website. DMD for Windows http://www.digitalmars.com/d/2.0/dmd-windows.html

The newest DMD2 source you can get here: https://github.com/D-Programming-Language


2). Settings in CodeBlocks.

You should add correct DMD pathes into CodeBlocks Global compiler settings

   2.1). "Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
   2.2). click "Compiler settings -> Other options", add  -m32  into the field;
   2.3). click "Linker settings", and add "D:\Program\DMD2\windows\lib\phobos.lib" into the "Link libraries";
   2.4). click "Search directories -> Compiler", and add "D:\Program\DMD2\src\phobos" into the field;
   2.5). click "Search directories -> Linker", and add "D:\Program\DMD2\windows\lib" into the field;
   2.6). click "Toolchain executables", add "D:\Program\DMD2\windows" into the "Compiler's installation directory" filed;
         (if you installed DMD2 correctly acc. to Installation setp, just click 'Auto-detect' button.)
   2.7). Additional: If you wan to specify the DMC (Digital Mars C/C++ Compiler) you can do like this:
         click "Toolchain executables -> Additional Paths", and add "D:\Program\DMC\bin" into the field.

The "D:\Program\DMD2" or "D:\Program\DMC\bin" here should change to your own DMD or DMC path in your system.


3). Testing D program in CodeBlocks.

In CodeBlocks, produce a D Application project, and input your own D code into the .d file in the project, then build/run.

Linux

At the time of this writing, Code::Blocks supports the following compilers in Linux:

Digital Mars D Compiler for Linux

Now Digital Mars D Compiler (DMD) supports 32bit and 64bit Linux, and 'support Linux library' is under construction. If you want to build D program in CodeBlocks on 32bit and 64bit Linux, please following the instructions as bellow.

1). Install DMD(2.0) into your Linux system.

You should correctly combine the DMD compiler and install it into your system. Please view the instructions on digitalmars.com website. DMD for Linux http://www.digitalmars.com/d/2.0/dmd-linux.html

The newest DMD2 source you can get here: https://github.com/D-Programming-Language


2). Settings in CodeBlocks.

A). 32bit Linux & 32bit DMD2.

On 32bit Linux, you should combine 32bit DMD2 from DMD2 source and install it into your system.

You should add correct DMD pathes into CodeBlocks Global compiler settings.

   A.1). "Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
   A.2). click "Compiler settings -> Other options", add  -m32  into the field.
   A.3). click "Linker settings", and add "/opt/dmd2/linux/lib32/libphobos2.a" into the "Link libraries". 
   A.4). click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
   A.5). click "Search directories -> Linker", and add "/opt/dmd2/linux/lib32" into the field. 
   A.6). click "Toolchain executables", add "/opt/dmd2/linux" into the "Compiler's installation directory" filed.
   A.7). change the value of "Program Files -> Linker for dynamic libs" to "gcc -m32 -lrt" or "gcc -lrt".

If you installed DMD2 to a different path, please modify "/opt/dmd2" to your own DMD2 path.


B1). 64bit Linux & 64bit DMD2.

On 64bit Linux, you can combine 64bit DMD2 from DMD2 source and install it into your system.

You should add correct DMD paths into CodeBlocks Global compiler settings.

   B1.1). "Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
   B1.2). click "Compiler settings -> Other options", add  -m64  into the field.
   B1.3). click "Linker settings", and add "/opt/dmd2/linux/lib64/libphobos2.a" into the "Link libraries". 
   B1.4). click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
   B1.5). click "Search directories -> Linker", and add "/opt/dmd2/linux/lib64" into the field. 
   B1.6). click "Toolchain executables", add "/opt/dmd2/linux" into the "Compiler's installation directory" filed.
   B1.7). change the value of "Program Files -> Linker for dynamic libs" to "gcc -m64 -lrt" or "gcc -lrt".

If you installed DMD2 to a different path, please modify "/opt/dmd2" to your own DMD2 path.


B2). 64bit Linux with 32bit DMD2.

On 64bit Linux, you can combine 32bit DMD2 with 64bit together from DMD2 source and install them into your system.

You should add correct DMD paths into CodeBlocks Global compiler settings.

   B2.1). "Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
   B2.2). click "Compiler settings -> Other options", add -m32 into the field.
   B2.3). click "Linker settings", and add "/opt/dmd2/linux/lib32/libphobos2.a" into the "Link libraries". 
   B2.4). click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
   B2.5). click "Search directories -> Linker", and add "/opt/dmd2/linux/lib32" into the field. 
   B2.6). click "Toolchain executables", add "/opt/dmd2/linux" into the "Compiler's installation directory" filed.
   B2.7). change the value of "Program Files -> Linker for dynamic libs" to "gcc -m32 -lrt".

If you installed DMD2 to a different path, please modify "/opt/dmd2" to your own DMD2 path.


3). Testing D program in CodeBlocks.

In CodeBlocks, produce a D Application project, and input your own D code into the .d file in the project, then build/run.

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 a compatible version Xcode Tools from http://developer.apple.com/tools/ (or http://developer.apple.com/downloads). You need the "Command Line Tools".

This will install Apple versions of:

http://www.gnu.org/software/gcc/

http://www.gnu.org/software/gdb/

http://www.gnu.org/software/make/

Setting up compiler switches

Usually you need to tweak the compiler options to be able to compile C++ applications - that's the stuff Xcode hides from your eyes, but you better should know. You need to point to the GNU compiler's C/C++ include folders, to the GNU linkers libraries folder and a adjust the compiler options to setup the GNU compiler root path. Those path's differ depending on what hardware (processor architecture) and what version of MacOS is used. For an Intel based Mac with MacOS 10.6.2 and Xcode v3.2.2 the following should work:

Compiler search directories ("include" folders):

/Developer/SDKs/MacOSX10.6.sdk/usr/include

/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1

Linker search directories ("library" folders):

/Developer/SDKs/MacOSX10.6.sdk/usr/lib

/Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1

Additional compiler flags:

-isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -gdwarf-2

Remote Compilation

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 functionality:

Installing Uniwin remote compiler
Using Xming for remote compilation

Misc. Custom Compilers

There are several user contributions for different (non-C/C++) compiler which are listed here:

https://wiki.codeblocks.org/index.php?title=User_documentation#Compilers