Nightly Cookbook

From CodeBlocks
Revision as of 16:54, 12 May 2006 by Sethjackson (Talk | contribs) (The new project format is incompatible with RC2 ;))

Jump to: navigation, search

This page is under construction by 'killerbot'. Just be patient, some day it will be finished.


This article will describe the process used in creating the nightly builds, and can be used as a guideline if you want to build Code::Blocks yourself. It is described as a sequence of 'manual' actions. While it is possible to automate several of these tasks via script, that is beyond the scope of this article. Current limitation : Windows unicode build.

Shopping List

In order to perform our build tasks, we will need several tools. Let's create an ingredient list for our cooking experiments :

  • a compiler
  • an initial build system
  • the Code::Blocks sources
  • zip program
  • svn (version control system)
  • wxWidgets

While we are at it, maybe someday we want to debug our programs, so let's add a debugger to the list :

  • debugger

Shopping Time


Let's start by shopping for the first item on our list, a compiler. Several compilers are available; some free, some expensive. Since the Code::Blocks developers build Code::Blocks using GCC, we might as well use that one. It is very standards compliant, though not the fastest one around. GCC on windows is available in several flavors. There are CygWin ports and MingW ports.

The easiest and cleanest port is MinGW. This is the compiler distributed with Code::Blocks when you download the official package (the one including the compiler). We can find MinGW at This post in the wiki describes how to install MinGW. We will stick to version 3.4.4, which works nicely.

First, a brief explanation of MinGW components:

  • gcc-core : the core of the GCC suite
  • gcc-g++ : the c++ compiler
  • mingw Runtime : implementation of the run time libraries
  • mingw utils : several utilities (implementation of smaller programs that GCC itself uses)
  • win32Api : the APIs for creating Windows programs
  • binutils : several utilities used in build environments
  • make : the Gnu make program, so you can build from make files
  • GDB : the Gnu debugger : for hunting those nasty bugs

I would suggest extracting (and installing for the GDB) everything in the C:\MinGW directory. The remainder of this article will assume that this is where you have put it. If you already have an installation of Code::Blocks that came bundled with MinGW (for example RC2), I still advise you to install MinGW as described here. A compiler does not belong under the directory tree of an IDE; they are two separate things. Code::Blocks just brings it along in the official versions so that the average user does not need to bother with this process. But, since you are reading this, you are no longer an average user. :-)

You may need to add the 'bin' directory of your MinGW installation to your path (example : C:\MinGW\bin). An easy way to do this is with the following command at the command prompt:

set path=%PATH%;C:\MinGW\bin;C:\MinGW\mingw32\bin;

Initial Build System

We could try to build Code::Blocks by using makefiles, but there is an easier way: let's build Code::Blocks by using ........ Code::Blocks. All we need to do is get hold of a pre-built version Code::Blocks.

First, download a nightly build. You can make your selection from here. The nightly builds are unicode versions, containing the core and contributed plug-ins.

Next, unpack the 7-zip file to any directory you like (e.g. C:\CodeBlocksTempNightly). If you don't have 7-zip, you can download it for free from the 7-zip website.

Now, Code::Blocks needs one more dll to work correctly: the WxWidgets dll. You can also download it at the nightly builds forum. Just unzip it into the same directory that you unpacked the Code::Blocks nightly build. It also needs the mingwm10.dll, but don't worry - we already have it. It's in the bin directory of our MinGW installation. So, it's important to make sure the bin directory of your MinGW installation is in your path variable (see above).

Finally, start up this new nightly build of Code::Blocks. It should discover the MinGW compiler we just installed.

Version Control System

In order to be able to retrieve the latest and greatest Code::Blocks sources, we need to install a Version Control System.

The Code::Blocks developers provide their sources through the SVN version control system. So, we need a client to access their svn repository of sources. A nice, easy client for Windows is TortoiseSVN, which is freely available from here. Download and install it, keeping all suggested settings.

Now, go create a directory wherever you like, for example D:\projects\CodeBlocks. Right click on that directory and choose from the pop-up menu : svn-checkout. In the dialog that pops up, fill in the following information:

 - Url of Repository : svn://
 - leave all other settings as they are

Now be patient while TortoiseSVN retrieves the most recent source files from the Code::Blocks repository into our local directory. Yes; all those Code::Blocks sources are coming your way!

For more info on SVN settings, see info on SVN settings.

All righty, time to continue our shopping session.


wxWidgets is a platform abstraction that provides an API that covers amongst many things, GUI, sockets, files, registry functionality. In that way when using this API you can create a platform independent program. Code::Blocks is a wxWidgets (here after : wx ) application, that means if you want to run Code::Blocks you needed the wx functionality, this can be provided in many flavours, could be a dll, or a static library, Code::Blocks uses wx as a dll, this dll can also be downloaded from the nightly build section of the forum. However if we want to build a wx application, we need to be able to include the headers of the wx sources, they will tell the compiler what (and how) the wx functionality is. So we need at least those headers, but next to this before we can use the dll to build our application, our application will need to link with the import libraries. So in addition we need those import libraries. Well, let's take it step by step. wx is provided as a zip file of it's sources, so we need to build that ourselves, well we already shopped for the MingW compiler, so we have all the tools we need at hand. Go download the wx sources (at time of writing : version 2.6.2) here, let's unzip it in D:\Projects, so we will end up with wx root directory D:\Projects\wxWidgets-2.6.2. We are going to mention the wx root directory from now on as <wxDir> Now we are gonna build the wxWidgets, yes we are. This is how we do it (make sure C:\MingW\bin is in your path, during the build some programs will be called that reside in the the MingW\bin directory), especially make has to be version 3.80 or above.

Now it is time to compile wxWidgets, open the command promt and change to the wxWidgets directory:

 cd <wxDir>\build\msw

Now we are on the right place we are first going to clean up the source:

 mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 clean

When everything is clean we can compile wxWidgets:

 mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1

This is going to take some time, got get yourself a nice ice-cream, a beer, ... Did you enjoy your refreshment, in the meantime have a little look in the directory <wxDir>\lib\gcc_dll : the import libraries and the dll have shown up, there's also a mswu\wx subdirectory at that position containing setup.h . Congratulations, you have build wxWidgets, let's do some more preliminary tasks before we get to the real deal of compiling Code::Blocks.


During the build of Code::Blocks several resources are going to be zipped in zip files, therefor the build process should have access to a zip.exe. We have to download that zip.exe and put it somewhere in our path (how about MingW\bin). Yo can download it for free from here and this is a direct link(32bit) to the most recent version at the time of writing. From the downloaded zip files it is sufficient to extract the zip.exe.


This brings us to the last preliminary task. The Code::Blocks code can be divided in 2 major parts : the core with internal plug-ins, and the contributed plug-ins. You always need to build the core/internal parts before building the contrib part. To build the internal part, you can use the Code::Blocks project file which you can find at (our Code::Blocks master directory is from now one mentioned as <cbDir>) <cbDir>\src\CodeBlocks.cbp. A workspace (which groups several projects together) for building the contrib plug-ins can be found at <cbDir>\src\ContribPlugins.workspace. But let's create a worksapce containing everything, and let's put that workspace in the master directory <cbDir>. Just use a regular text editor and create a file with the name "CbProjects.workspace" and give it the following content :

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 <Workspace title="Workspace">
   <Project filename="src\CodeBlocks.cbp" active="1" />
   <Project filename="src\plugins\contrib\codestat\codestat.cbp" />
   <Project filename="src\plugins\contrib\copystrings\copystrings.cbp" />
   <Project filename="src\plugins\contrib\dragscroll\dragscroll.cbp" />
   <Project filename="src\plugins\contrib\devpak_plugin\DevPakPlugin.cbp" />
   <Project filename="src\plugins\contrib\help_plugin\help-plugin.cbp" />
   <Project filename="src\plugins\contrib\keybinder\keybinder.cbp" />
   <Project filename="src\plugins\contrib\profiler\cbprofiler.cbp" />
   <Project filename="src\plugins\contrib\source_exporter\Exporter.cbp" />
   <Project filename="src\plugins\contrib\wxSmith\wxSmith.cbp" />

We will use this workspace to build all parts of Code::Blocks.

Building Code::Blocks

Finally we have arrived at the final step, our final goal. Run the Code::Blocks executable from your nightly build download. Choose from the File menu : Open, and browse for our above created workspace, and open it up. be a little patient while Code::Blocks is parsing everything, and Code::Blocks will ask us for 2 global variables, these global variables will tell the nightly Code::Blocks where it can find wxWidgets (remember : header files and import libraries) and where it can find .... Code::Blocks, this is needed for the contrib plug-ins, they need to know (as for any user created plug-in) where the sdk (Code::Blocks header files) are. These are the values in our case :

- wx : <wxDir>
- Code::Blocks (cb) : <cbDir>\src

Now go to the Project Menu and choose (re)build workspace, and off you go, watch how Code::Blocks is building Code::Blocks. Once everything has build, open up a console in <cbDir>\src and run the command "update.bat', this will transfer all builded deliverables from <cbDir>\src\devel to <cbDir>\src\output and in the meantime strip of all debugging symbols. Note this step is very important, do never ever forget it. Now you can copy the wx dll builded before both in that output and devel directory. You can close your Code::Blocks now (that was the downloaded nightly remember).

Time to test : in that output directory start up the CodeBlocks.exe, and there you go, your home-build Code::Blocks is running. Enjoy !!!