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.
Let’s get started with the installation Step 1. This should take a few seconds. Click okay and move on to the next step. Click on Security and Privacy. Click on Open Anyway to resume installing Code Blocks. Your Mac will ensure whether you want to open it. Hello Friends, In this tutorial, I will show you how to install and setup code blocks on mac os x Catalina to run C/C program. I have explained the whole p. Code Blocks is an open source, free, C, C and Fortran IDE cross-platform that provides a ton of options. It is a no-cost CIDE created with for users who have high demands. Those behind this free software program designed it for extensive user customization and maximum flexibility. 3 Mac OS X; Windows Code::Blocks / TDM-GCC. First, install TDM-GCC 64bit version: TDM-GCC (the second link on that page) Then, install Code::Blocks (first windows download link, no need for the packaged mingGW). Unless you want to mess with Code::Blocks compiler settings).
- 2Windows
- 2.1MinGW/GCC
- 3Linux
- 4Mac OS X
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:
- MinGW GCC C/C++ Free Compiler, including GFortran
- Cygwin GCC C/C++ Free Compiler
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
Code Blocks Mac Os X Compiler 10
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:
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
Solution
Code Blocks With Compiler
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:
See also: Installing Cygwin Compiler
(Unofficial) TDM - 'Twilight Dragon Media'
These packages are called TDM's GCC/mingw32 Builds and can be obtained from [4] or [5].
Packages required (suggested) for TDM's GCC/mingw32 Builds v4.4.1-tdm-2 SJLJ:...which can be found here: [6] 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 dmbinsc.ini in a text editor, and replace the line
with
Intel C++ Compiler
Please note that on Windows platform, Intel C/C++ compiler requires Microsoft Visual C++[7] 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[8] 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 FilesIntelCompilerC++10.1.020IA32 , 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. It may look like-
- 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-
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
The 'D:ProgramDMD2' or 'D:ProgramDMCbin' 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.
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.
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.
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:
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:
The following are methods to compile Sauerbraten for the three main target OSes (Windows, Linux and Mac OS X).
- 1Windows
Windows
Code::Blocks / TDM-GCC
First, install TDM-GCC 64bit version: TDM-GCC (the second link on that page)Then, install Code::Blocks (first windows download link, no need for the packaged mingGW)
Boot up Code Blocks, click 'Open An Existing Project', navigate to sauerbraten/src/vcpp/ and select sauerbraten.cbp
In the menu bar click Build, -> Build, and it will compile to your sauerbraten folder. After it is done (you will see blue text saying 0 errors and such) you can run sauerbraten.bat
Code::Blocks / MinGW
Note: the following method does not work with the more recent versions, use tdm gcc 64 bit.
To compile Sauerbraten under Windows, download Code::Blocks and install it. After installation has completed, load up Code::Blocks, go to File > Open. Navigate to 'sauerbraten/src/mingw' and select 'sauerbraten.cbp'. Once the project has loaded, go to Build > Build, and wait patiently for sauerbraten to compile. Once it has finished compiling, you will find the EXE in 'sauerbraten/bin' under the name 'sauerbraten-mingw.exe'. Simply edit your .bat launcher to use this executable instead, and enjoy.
The version of MinGW that ships with Code::Blocks was known to be buggy, especially when compiling Sauerbraten. You should probably obtain the latest version from the Sourceforge download page and install it (to the default location, unless you want to mess with Code::Blocks compiler settings).
Microsoft Visual C++ Express
An alternative method for compiling under Windows is by using Microsoft's Visual C++ 2008 Express Edition. This method is slightly more painful than compiling with Code::Blocks and MinGW, but if you are more familiar with the VC++ line of IDEs, then it can be worth it.To start, navigate to sauerbratensrcvcpp, double-click on sauerbraten.sln, and click through the process of converting the solution to the latest format. Now, you should have the solution open in front of you. Minimize it (you should still have sauerbratensrcvcpp open) and open sauerbraten.rc in Notepad or your preferred text editor. The top line should read #include 'afxres.h'. Now, this header file is deprecated, so change it to the more recent winresrc.h. (Note that you should have the Platform SDK installed, which you probably do if you're developing with VC++; you should have the include directories set up, because that's where the header is.) Save and close. One more thing to go: Right click on sauerbraten in the solution explorer, go to Properties, expand Linker, go to General, and change ....binsauerbraten.exe to something like ....binsauerbraten-vcpp.exe, since you probably don't want to replace the vanilla Sauerbraten executable. Hit OK. Now you're ready! Hit Build > Build Solution, and wait patiently for it to compile. As above, edit your .bat launcher (or create a new one) to use the executable you compiled. Have fun!
MSYS
Yet another alternative method exists for Windows: that of compiling using the cmd replacement MSYS. Information and download links can be had at MinGW.org. Once you have both MSYS and the MinGW compiler, the compile process is strikingly similar to Linux's: Open up MSYS, cd into Sauerbraten's src directory, and perform, as shown below, the 'make-dance'.
Linux
Provided they have GCC installed (pulled in with the package 'build-essential' on a lot of distributions) and the required SDL development libraries (libsdl-image1.2-dev, libsdl-mixer-1.2-dev), the users of Linux need only perform the usual make-dance.Change into the directory 'sauerbraten/src' (in a terminal) and then run
Of course, after this, you need to make sure you run the native_* binaries, not the linux_* binaries! (The sauerbraten_unix script handles this for you.)
Mac OS X
Todo...There is an Xcode project file, or you can use Code::Blocks for Mac.