Beruflich Dokumente
Kultur Dokumente
1 of 10
http://wiki.codeblocks.org/index.php/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.
Contents
1 Compiler-neutral setup steps
2 Windows
2.1 MinGW/GCC
2.1.1 Official MinGW.org
2.1.2 HOWTO: Use Cygwin 1.7 with Code::Blocks
2.1.3 (Unofficial) TDM - "Twilight Dragon Media"
2.2 Microsoft Visual C++
2.3 Borland C++ Compiler 5.5
2.4 Digital Mars C/C++ Free Compiler
2.5 Intel C++ Compiler
2.6 Digital Mars D Compiler for Windows
3 Linux
3.1 Digital Mars D Compiler for Linux
3.2 Downloading the GNU GCC compiler & GDB debugger
4 Mac OS X
4.1 Downloading the GNU GCC compiler & GDB debugger
4.2 Setting up compiler switches
5 Remote Compilation
6 Misc. Custom Compilers
2 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
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:
MinGW/GCC
The official MinGW website is at mingw.org (http://www.mingw.org). A MinGW-bundled version of the latest
Code::Blocks release is available from the Code::Blocks download page (http://www.codeblocks.org/downloads
/5#windows). 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] (http://forums.codeblocks.org/index.php
/topic,10508.0.html) or [2] (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.
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 (http://www.mingw.org), here: [3] (http://sourceforge.net
/projects/mingw/files/).
03-04-2016 03:16
3 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
-g
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.
03-04-2016 03:16
4 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
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
Packages required (suggested) for TDM's GCC/mingw32 Builds v4.4.1-tdm-2 SJLJ: ...which can be found here:
[6] (http://sourceforge.net/projects/tdm-gcc/files/) 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
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
(http://www.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.
NOTE: At some point, you will be asked to register with Borland and fill out a survey. Registration is free.
03-04-2016 03:16
5 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
with
INCLUDE="%@P%\..\stlport\stlport";"%@P%\..\include";"%@P%\..\mfc\include";%INCLUDE%
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-
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.
03-04-2016 03:16
6 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
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 likeC:\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.
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).
2.2).
2.3).
2.4).
2.5).
2.6).
"Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
click "Compiler settings -> Other options", add -m32 into the field;
click "Linker settings", and add "D:\Program\DMD2\windows\lib\phobos.lib" into the "Link libraries";
click "Search directories -> Compiler", and add "D:\Program\DMD2\src\phobos" into the field;
click "Search directories -> Linker", and add "D:\Program\DMD2\windows\lib" into the field;
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.
03-04-2016 03:16
7 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
Linux
At the time of this writing, Code::Blocks supports the following compilers in Linux:
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.
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).
A.2).
A.3).
A.4).
A.5).
A.6).
A.7).
"Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
click "Compiler settings -> Other options", add -m32 into the field.
click "Linker settings", and add "/opt/dmd2/linux/lib32/libphobos2.a" into the "Link libraries".
click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
click "Search directories -> Linker", and add "/opt/dmd2/linux/lib32" into the field.
click "Toolchain executables", add "/opt/dmd2/linux" into the "Compiler's installation directory" filed.
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).
B1.2).
B1.3).
B1.4).
B1.5).
"Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
click "Compiler settings -> Other options", add -m64 into the field.
click "Linker settings", and add "/opt/dmd2/linux/lib64/libphobos2.a" into the "Link libraries".
click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
click "Search directories -> Linker", and add "/opt/dmd2/linux/lib64" into the field.
03-04-2016 03:16
8 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
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).
B2.2).
B2.3).
B2.4).
B2.5).
B2.6).
B2.7).
"Settings -> Compiler and debugger settings" and choose compiler to "Digital Mars D Compiler";
click "Compiler settings -> Other options", add -m32 into the field.
click "Linker settings", and add "/opt/dmd2/linux/lib32/libphobos2.a" into the "Link libraries".
click "Search directories -> Compiler", and add "/opt/dmd2/src/phobos" into the field.
click "Search directories -> Linker", and add "/opt/dmd2/linux/lib32" into the field.
click "Toolchain executables", add "/opt/dmd2/linux" into the "Compiler's installation directory" filed.
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.
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:
03-04-2016 03:16
9 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
http://www.gnu.org/software/gdb/
http://www.gnu.org/software/make/
/Developer/SDKs/MacOSX10.6.sdk/usr/include
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1
/Developer/SDKs/MacOSX10.6.sdk/usr/lib
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1
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
10 of 10
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
03-04-2016 03:16