Difference between revisions of "Nightly Cookbook"

From Code::Blocks
Line 110: Line 110:
  
 
Time to test : in that output directory start up the CodeBlocks.exe, and there you go, your home-build Code::Blocks is running. Enjoy !!!
 
Time to test : in that output directory start up the CodeBlocks.exe, and there you go, your home-build Code::Blocks is running. Enjoy !!!
 
(woops, time to go, till next time)
 
 
TO BE CONTINUED
 

Revision as of 22:44, 24 March 2006

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

Introduction

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, it is surely possible to script automate several of these tasks. But that's beyond the scope of the original 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

Compiler

Let's start by shopping for our first item on the list, a compiler. Several compilers are available, some free, some expensive. Since Code::Blocks is being build by the developers with GCC, we might as well use that one. It is very standard conformant, though not the fastest one around. GCC on windows is available in several flavors, there are CygWin ports, MingW ports. The most easiest and cleanest port is MingW, once again this is what Code::Blocks distributes itself, when you download the official package (the one including the compiler). We can find MingW at www.mingw.org. This other post in the wiki describes what you need. Here we also stick to the 3.4.4 version, which works nicely. Though let's put a very small explanation :

  • 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 uses itself)
  • win32Api : if you want to create Windows programs, here's the headers/API.
  • 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 also suggest to extract (and install for the GDB) everything in C:\MingW, the remainder of this article will assume this is where you have put it. In case you already had an installation of Code::Blocks (for example RC2) and you installed the version coming with MingW, I still would like to advice you to install MingW as described here. A compiler does not belong under the directory tree of an IDE, it are 2 seperate things. Code::Blocks just brings it along in the official versions, so the average user does not need to bother, but since you are reading this, you are no longer an average user. :-) It is advised to add your 'bin' directory of your MingW installation (example : C:\MingW\bin) to your path.

Initial Build System

We could try to build Code::Blocks by using makefiles, but we can do this way nicer : let's build Code::Blocks by using ........ Code::Blocks. So no chicken and egg problem. All we need to do, is get hold of a pre-build Code::Blocks. Well, just download a nightly build, make your selection from [/index.php?board=20.0 here]. The nighly builds are unicode versions, containing the core and contributed plug-ins. Just unpack the 7-zip file to any directory you like (eg : C:\CodeBlocksTempNightly). Go ahead, start up that Code::Blocks, it should discover the MingW compiler we installed just before. Well, one more thing. Code::Blocks needs one more dll to work correclty, the wx widgets dll, you can also download it at the nightly builds forum. Just unzip it in the same directory as where you unpacked the Code::Blocks nightly build. To be really honest, 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 make sure the bin directory of your MingW installation is in the path. If you don't have 7-zip, you can download it for free from here.

Version Control System

In order to be able to retrieve the Code::Blocks sources we need to install a Version Control System. The Code::Blocks developers provide their sources through the "SVN" version control system. Therefor we need a client to access that 'svn'-repository of sources. A nice and easy client for Windows is TortoiseSvn, which is freely available from here. Download and install it, keep 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 pop's up fill in the following fields :

 - Url of Repository : svn://svn.berlios.de/codeblocks/trunk
 - leave all other settings as they are

Now be patient wil svn is retrieving all recent sources from the repository and is copying them into our directory. Yes, yes, all those Code::Blocks sources are coming your way. More info on svn settings : Info on svn settings.

All righty, time to continue are shopping session.

wxWidgets

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.

 - open up a console in <wxDir>\build\msw
 - clean up the source tree : mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 clean
 - actual build : mingw32-make -f makefile.gcc USE_XRC=1 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 direcory <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 read deal of compiling Code::Blocks.

Zip

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.


Workspace

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" ?>
<CodeBlocks_workspace_file>
 <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" />
 </Workspace>
</CodeBlocks_workspace_file>


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 the 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 !!!