Difference between revisions of "Installing a supported compiler"

From Code::Blocks
(Cleanup, some updating to Windows category)
Line 1: Line 1:
 
[[Category:User Documentation]]
 
[[Category:User Documentation]]
When you launch Code::Blocks for the first time, it will scan the system for any supported compilers (it takes virtually no time). After this scan completes, Code::Blocks will have been configured for the found compiler(s). Code::Blocks will also be configured even for compilers that were not found (default installation settings will be used for each of those compilers).
+
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.
  
For more info on how to download and install each of the above compilers, please read on.
+
This article is a guide for obtaining, installing, and configuring the various compilers that Code::Blocks can use.
  
  
==Windows==
+
== Windows ==
Currently supported compilers, at the time of this writing are:
+
 
 +
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:
 
* [http://www.mingw.org MinGW GCC C/C++ Free Compiler, including G77 (Fortran)]
 
* [http://www.mingw.org MinGW GCC C/C++ Free Compiler, including G77 (Fortran)]
 
* [http://mspgcc.sourceforge.net/ MSP430 GCC C/C++]
 
* [http://mspgcc.sourceforge.net/ MSP430 GCC C/C++]
Line 18: Line 21:
 
* [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]
  
=== Downloading the GNU GCC compiler & GDB debugger ===
+
=== MinGW/GCC ===
 +
The official MinGW website is at [http://www.mingw.org mingw.org].
  
Go to MinGW's [http://www.mingw.org/download.shtml downloads] page and download the file named <code>MinGW-x.y.z.exe</code>, where x, y and z are version numbers. At the time of this writing, this file is <code>MinGW-3.1.0-1.exe</code>. If you consider yourself lucky, you might also try <code>MinGW-3.2.0-rc-3.exe</code>. It's not a stable release yet, but it works and lacks some bugs the older version has.
+
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.
These setup files contain everything needed to compile and debug windows programs.
 
  
=== Downloading the Microsoft Visual C++ Free Toolkit 2003 ===
+
You can also install MinGW yourself, by using an automatic downloader/installer or by downloading and unpacking the desired packages by hand. If you don't install MinGW in C:\MinGW, you'll need to update the configuration of GCC in Code::Blocks.
 
====This no longer works as discribed since the Toolkit was removed in favor of the 2005 release.====
 
  
 +
=== Microsoft Visual C++ ===
 +
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].
  
Go to this [http://msdn.microsoft.com/visualc/vctoolkit2003 MSDN site] and click on the link labeled "Download the Visual C++ Toolkit 2003". This will download the setup file.
+
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.
 
 
NOTE: ''This download is <u>not sufficient</u> for building windows programs. You will also have to download and install the [http://www.microsoft.com/msdownload/platformsdk/instmsi.htm Microsoft Platform SDK]''...
 
 
 
=== Downloading the Borland C++ Compiler 5.5 ===
 
  
 +
=== 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.''
 
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.
 
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.
  
=== Downloading the Digital Mars C/C++ Free Compiler ===
+
=== Digital Mars C/C++ Free Compiler ===
 
 
 
Go to [http://www.digitalmars.com/download/dmcpp.html DigitalMars]. Accept the license agreement and you'll be redirected to a page containing download links.  
 
Go to [http://www.digitalmars.com/download/dmcpp.html DigitalMars]. Accept the license agreement and you'll be redirected to a page containing download links.  
  
Line 52: Line 51:
 
  INCLUDE="%@P%\..\stlport\stlport";"%@P%\..\include";"%@P%\..\mfc\include";%INCLUDE%
 
  INCLUDE="%@P%\..\stlport\stlport";"%@P%\..\include";"%@P%\..\mfc\include";%INCLUDE%
  
=== Configuring Code::Blocks to use the Intel C++ Compiler ===
+
=== Intel C++ Compiler ===
 
+
Please note that on Windows platform, Intel C/C++ compiler requires ''Microsoft Visual C++[http://www.microsoft.com/express/download/offline.aspx]'' 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[http://www.microsoft.com/downloads/details.aspx?FamilyID=e6e1c3df-a74f-4207-8586-711ebe331cdc&DisplayLang=en]'' shall be installed in order to compile Windows app.
'''Configuring Intel C/C++ Compiler on Windows (Applicable to Code::Blocks 8.02 and onwards)'''
 
 
 
Please note that on Windows platform, Intel C/C++ compiler requires ''MS compiler[http://www.microsoft.com/express/download/offline.aspx]'' 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[http://www.microsoft.com/downloads/details.aspx?FamilyID=e6e1c3df-a74f-4207-8586-711ebe331cdc&DisplayLang=en]'' 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.
 
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.
Line 80: Line 76:
  
  
 +
== Linux ==
  
'''Note: this info is for 1.0RC1 and previous versions, now C::B has direct support for Intel C++.'''
+
At the time of this writing, Code::Blocks supports the following compilers in Linux:
 
 
After various user requests, we decided to post here the info to support the Intel Compiler on CodeBlocks. This should be easy, since the Intel Compiler can emulate the MSVC++ compiler.
 
 
 
* change MS Toolkit linker from <tt>cl.exe</tt> to <tt>icl.exe</tt>
 
* add <tt>(installation path to the Intel C++)\Ia32\Bin</tt> to the '''Programs > Extra paths'''
 
* add <tt>-D_USE_INTEL_COMPILER</tt> to '''Compiler options'''
 
* add <tt>(installation path to the Intel C++)\Ia32\Include</tt> and <tt>\lib</tt> to the '''Global compiler options > Directories'''
 
* add some options like <tt>/QaxK</tt> to the '''Compiler options''' (icl -help)
 
 
 
==Linux==
 
Currently supported compilers, at the time of this writing are:
 
 
* [http://gcc.gnu.org/ GNU GCC C/C++ Free Compiler]
 
* [http://gcc.gnu.org/ GNU GCC C/C++ Free Compiler]
 
* [http://sdcc.sourceforge.net/ Small Device Free C Compiler (SDCC)]
 
* [http://sdcc.sourceforge.net/ Small Device Free C Compiler (SDCC)]

Revision as of 18:30, 21 July 2008

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.


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.

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.

You can also install MinGW yourself, by using an automatic downloader/installer or by downloading and unpacking the desired packages by hand. If you don't install MinGW in C:\MinGW, you'll need to update the configuration of GCC in Code::Blocks.

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

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


Linux

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:

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


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.