Code::Blocks Manual
Version 1.0
The instructions for Listing 3 and Listing 4 are official documentations of the CodeBlocks Wiki site and available in english only.
The below illustration shows the design of the CodeBlocks user interface.
The status bar gives an overview of the following settings:
CodeBlocks offers a very flexible and comprehensive project management. The following text will address only some of the features of the project management.
In CodeBlocks, the sources and the settings for the build process are stored in a project file <name>.cbp. C/C++ sources and the corresponding header files are the typical components of a project. The easiest way to create a new project is executing the command ’File’ /’Project’ and selecting a wizard. Then you can add files to the project via the context menu ’Add files’ in the Management window. CodeBlocks governs the project files in categories according to their file extensions. These are the preset categories:
The settings for types and categories of files can be adjusted via the context menu ’Project tree’ /’Edit file types & categories’ . Here you can also define custom categories for file extensions of your own. For example, if you wish to list linker scripts with the *.ld extension in a category called Linkerscript, you only have to create the new category.
In CodeBlocks, so-called notes can be stored for a project. These notes should contain short descriptions or hints for the corresponding project. By displaying this information during the opening of a project, other users are provided with a quick survey of the project. The display of notes can be switched on or off in the Notes tab of the Properties of a project.
CodeBlocks is supplied with a variety of project templates which are displayed when creating a new project. However, it is also possible to store custom templates for collecting your own specifications for compiler switches, the optimisation to be used, machine-specific switches etc. in templates. These templates will be stored in the Documents and Settings\<user>\Application Data\codeblocks\UserTemplates directory. If the templates are to be open to all users, they have to be copied to a corresponding directory of the CodeBlocks installation. These templates will then be displayed at the next startup of CodeBlocks under ’New’ /’ Project’ /’User templates’ .
In projects it is necessary to have different variants of the project available. Variants are called Build Targets. They differ with respect to their compiler options, debug information and/or choice of files. A Build Target can also be outsourced to a separate project. To do so, click ’Project’ /’Properties’ , select the variant from the tab ’Build Targets’ and click the ’Create project from target’ button (see Figure 1.2).
Projects can be further structured in CodeBlocks by so-called Virtual Targets. A frequently used project structure consists of two Build Targets, one ’Debug’ Target which contains debug information and one ’Release’ Target without this information. By adding Virtual Targets via ’Project’ /’Properties’ /’Build Targets’ individual Build Targets can be combined. For example, a Virtual Target ’All’ can create the Targets Debug and Release simultaneously. Virtual Targets are shown in the symbol bar of the compiler under Build Targets.
CodeBlocks makes it possible to perform additional operations before or after compiling a project. These operations are called Prebuilt or Postbuilt Steps. Typical Postbuilt Steps are:
Example
Creating a Disassembly from an object under Windows. Piping to a file requires calling cmd with the /c option.
Archiving a project can be another example for a Postbuilt Step. For this purpose, create a Build Target ’Archive’ and include the following instruction in the Postbuilt Step:
With this command, the active project and its sources, header and objects will be packed as a zip file. In doing so, the Built-in variables $(PROJECT_NAME) and $(TODAY), the project name and the current date will be extracted (see Listing 3.2). After the execution of the Target ’Archive’, the packed file will be stored in the project directory.
In the share/codeblocks/scripts directory you will find some examples for scripts. You can add a script via menu ’Settings’ /’Scripting’ and register in a menu. If you execute e.g. the script make_dist from the menu then all files belonging to a project will be compressed in an archive <project>.tar.gz.
CodeBlocks offers the possibility of using menu actions in scripts. The script represents another degree of freedom for controlling the generation of your project.
In CodeBlocks, multiple projects can be open. By saving open projects via ’File’ /’Save workspace’ you can collect them in a single workspace under <name>.workspace. If you open <name>.workspace during the next startup of von CodeBlocks, all projects will show up again.
Complex software systems consist of components which are managed in different CodeBlocks projects. Furthermore, with the generation of such software systems, there are often dependencies between these projects.
Example
A project A contains fundamental functions which are made available to other projects in the form of a library. Now, if the sources of this project are modified, then the library has to be rebuilt. To maintain consistency between a project B which uses the functions and project A which implements the functions, project B has to depend on project A. The necessary information on the dependencies of projects is stored in the relevant workspace, so that each project can be created separately. The usage of dependencies makes it also possible to control the order in which the projects will be generated. The dependencies for projects can be set via the selecting the menu ’Project’ /’Properties’ and then clicking the ’Project’s dependencies’ button.
In the Management window of the Project View, Assembler files are shown in the ASM Sources category. The user can change the listing of files in categories (see 1.1). Right-clicking one of the listed Assembler files will open a context menu. Select ’Properties’ to open a new window. Now select the ’Build’ tab and activate the two fields ’Compile file’ and ’Link file’. Then select the ’Advanced’ tab and execute the following steps:
The CodeBlocks variables are marked by $ (see Listing 3.4). They are set automatically so that you only have to replace the Assembler option <asopt> by your own settings.
The company’s Coding Rules require source files to have a standard design. CodeBlocks makes it possible to include a predefined content at the beginning of a file automatically when creating new C/C++ sources and headers. This predefined content is called default code. This setting can be selected under ’Stettings’ /’Editor’ Default Code. A new file can be created via the menu ’File’ /’New’ /’File’ .
Example
A lot of typing can be saved in CodeBlocks by defining abbreviation. This is done by selecting ’Settings’ /’Editor’ and defining the abbreviations under the name <name>, which can then be called by the keyboard shortcut Ctrl-J (see Figure 1.3).
Parametrisation is also possible by including variables $(NAME) in the abbreviations.
When performing the abbreviation <name> in the source text and performing Ctrl-J, the content of the variable is requested and included.
CodeBlocks settings are saved as application data in a file called <user>.conf in the codeblocks directory. This configuration file contains information such as the last opened projects, settings for the editor, display of symbol bars etc. By default, the ’default’ personality is set so that the configuration is stored in the file default.conf. If CodeBlocks is called from the command line with the parameter --personality=myuser, the settings will be stored in the file myuser.conf. If the profile does not exist already, it will automatically be created. This procedure makes it possible to create the corresponding profiles for different work steps. If you start CodeBlocks from the command line with the additional parameter--personality=ask, a selection box will be displayed for all the available profiles.
The CodeBlocks settings are stored in the default.conf profile in the codeblocks directory of your Application Data. When using personalities (see Listing 1.10.3), the configuration details will be stored in the <personality>.conf file.
The tool cb_share_conf, which can be found in the CodeBlocks installation directory, is used for managing and storing these settings.
If you wish to define standard settings for several users of a computer, the configuration file default.conf has to be stored in the directory \Documents and Settings\Default User\Application Data\codeblocks. During the first startup, CodeBlocks will copy the presettings from ’Default User’ to the application data of the current users.
To create a portable version of CodeBlocks on a USB stick, proceed as follows. Copy the CodeBlocks installation to a USB stick and store the configuration file default.conf in this directory. The configuration will be used as a global setting. Please take care that the file is writeable, otherwise changes of the configuration cannot be stored.
In CodeBlocks there are different ways of quick navigation between files and functions. Setting bookmarks is a typical procedure. Via the shortcut Ctrl-B a bookmark is set or deleted in the source file. Via Alt-PgUp you can jump to the previous bookmark, and via Alt-PgDn you can jump to the next bookmark.
If you select the workspace or a project in the workspace in the project view you will be able to search for a file in the project. Just select ’Find file’ from the context menu, then type the name of the file and the file will be selected. If you hit return this file will be opened in the editor (see Figure 1.4).
In CodeBlocks you can easily navigate between header/source files like:
CodeBlocks offeres several ways of searching within a file or directory. The dialogue box for searching is opened via ’Search’ /’Find’ (Ctrl-F) or ’Find in Files’ (Ctrl-Shift-F).
Alt-G and Ctrl-Alt-G are another useful functions. The dialogue which will open on using this shortcut, lets you select files/functions and then jumps to the implementation of the selected function (see Figure 1.6) or opens the selected file in the editor. You may use wildcards like * or ? etc. for an incremental search in the dialog.
In the editor, you can switch between the tabs with the open files via Ctrl-Tab. Alternatively you can set ’Use Smart Tab-switching scheme’ in ’Settings’ /’Notebook appearance’ , then Ctrl-Tab will bring up an Open Tabs window in which all the open files will be listed which can then be selected by mouse-click (see Figure 1.7). You can use the shortcut Ctrl-Tab in the management window to switch between the different tabs.
A common procedure when developing software is to struggle with a set of functions which are implemented in different files. The Browse Tracker plugin will help you solve this problem by showing you the order in which the files were selected. You can then comfortably navigate the function calls (see Listing 2.8).
The display of line numbers in CodeBlocks can be activated via ’Settings’ /’General Settings’ in the field ’Show line numbers’. The shortcut Ctrl-G or the menu command ’Search’ /’Goto line’ will help you jump to the desired line.
The CodeBlocks Management window offers a tree view for symbols of C/C++ sources for navigating via functions or variables. As the scope of this view, you can set the current file or project, or the whole workspace.
The following categories exist for the symbols:
Structures and classes are displayed below the pre-processor symbols. If a category is selected by mouse-click, the found symbols will be displayed in the lower part of the window (see Figure 1.8). Double-clicking the symbol will open the file in which the symbol is defined or the function implemented, and jumps to the corresponding line.
The CodeBlocks development environment supports the inclusion of external help files via the menu ’Settings’ /’Environment’ . Include the manual of your choice in the chm format in ’Help Files’ select ’this is the default help file’ (see Figure 1.9). The entry $(keyword) is a placeholder for a select item in your editor. Now you can select a function in an opened source file in CodeBlocks by mouse-click, and the corresponding documentation will appear while pressing F1.
If you have included multiple help files, you can select a term in the editor and choose a help file from the context menu ’Locate in’ for CodeBlocks to search in.
In CodeBlocks you can add even support for man pages. Just add a entry ’man’ and specify the path as follows.
CodeBlocks provides an ’Embedded HTML Viewer’, which can be used to display simple html file and find keywords within this file. Just configure the path to the html file, which should be parsed and enable the checkbox ’Open this file with embedded help viewer’ via the menu ’Settings’ /’Environment’ /’Help Files’ .
Including external tools is possible in CodeBlocks via ’Tools’ /’Configure Tools’ /’Add’ . Built-in variables (see Listing 3.2) can also be accessed for tool parameters. Furthermore there are several kinds of launching options for starting external applications. Depending on the option, the externally started applications are stopped when CodeBlocks is quit. If the applications are to remain open after quitting CodeBlocks, the option ’Launch tool visible detached’ must be set.
In this chapter we will present some useful settings in CodeBlocks.
CodeBlocks provides a feature to track modifications within a source file and to show a bar in the margin for the changes. Modifications are marked with a yellow changebar and modifications that are already saved will use a green changebar (see Figure 1.11). You can navigate between your changes via the menu ’Search’ /’Goto next changed line’ or ’Search’ /’Goto previous changed line’ . The same functionality is also accessible via the shortcuts Ctrl-F3 and Ctrl-Shift-F3.
This feature can be enabled or disabled with the checkbox ’Use Changebar’ in the menu ’Settings’ /’Editor’ /’Margins and caret’ .
Data can be exchanged between CodeBlocks and other applications. For this interprocess communication DDE (Dynamic Data Exchange) is used for windows and under different operating systems it is a TCP based communication.
With this interface different commands with the following syntax can be sent to a CodeBlocks instance.
These commands are currently available:
The command
uses the parameter, in our case it is a file specified with an absolute path, and opens it in an existing CodeBlocks instance or starts a first instance if required.
This command opens a file at a given line number in a CodeBlocks instance. The line number is specified with :line.
Set the focus to the CodeBlocks instance. A parameter must not be passed.
The configuration for an operating system is specified by so-called environmental variables. The environmental variable PATH for example contains the path to an installed compiler. The operating system will process this environmental variable from beginning to end, i.e. the entries at the end will be searched last. If different versions of a compiler or other applications are installed, the following situations can occur:
So it might be the case that different versions of a compilers or other tools are mandatory for different projects. One possibility in such a case is to change the environmental variables in the system control for every project. However, this procedure is error-prone and not flexible. For this requirement, CodeBlocks offers an elegant solution. Different configurations of environmental variables can be created which are used only internally in CodeBlocks. Additionally, you can switch between these configurations. The Figure 1.12 shows the dialogue which you can open via ’Environment Varibales’ under ’Settings’ /’Environment’ . A configuration is created via the ’Create’ button.
Access and scope of the environmental variables created here, is limited to CodeBlocks. You can expand these environmental variables just like other CodeBlocks variables via $(NAME).
Example
You can write the used environment into a postbuild Step (see 1.6) in a file <project>.env and archive it within your project.
or under Linux
Depending on the task in hand, it can be useful to have different configurations or views in CodeBlocks and to save these configurations/views. By default, the settings (e. g. show/hide symbol bars, layout, etc.) are stored in the default.conf configuration file. By using the command line option --personality=ask during the start of CodeBlocks, different settings can be selected. Apart from this global setting, a situation might occur where you wish to switch between different views of windows and symbol bars during a session. Editing files and debugging projects are two typical examples for such situations. CodeBlocks offers a mechanism for storing and selecting different perspectives to prevent the user from frequently having to open and close windows and symbol bars manually. To save a perspective, select the menu ’View’ /’Perspectives’ /’Save current’ and enter a name at <name>. The command ’Settings’ /’Editor’ /’Keyboard shortcuts’ /’View’ /’Perspectives’ /’<name>’ allows a keyboard shortcut to be defined for this process. This mechanism makes it possible to switch between different views by simply using hot keys.
If several projects or files are opened at the same time, the user needs a way to switch quickly between the projects or files. CodeBlocks has a number of shortcuts for such situations.
During the build process of a project, the compiler messages are displayed in the Messages window in the Build Log tab. If you wish to receive detailed information, the display can be extended. For this purpose click ’Settings’ /’Compiler and Debugger’ and select ’Other Settings’ in the drop-down field.
Take care that the correct compiler is selected. The ’Full command line’ setting in the Compiler Logging field outputs the complete information in the Build Log. In addition, this output can be logged in a HTML file. For this purpose select ’Save build log to HTML file when finished’. Furthermore, CodeBlocks offers a progress bar for the build process in the Build Log window which can be activated via the ’Display build progress bar’ setting.
CodeBlocks offers a very efficient editor. This editor allows you to change the size in which the opened text is displayed. If you use a mouse with a wheel, you only need to press the Ctrl key and scroll via the mouse wheel to zoom in and out of the text.
When editing text files, e. g. *.txt, within CodeBlocks, it might be useful to have the text wrapped, meaning long lines will be displayed in several lines on the screen so that they can be properly edited. The ’Word wrap’ function can be activated via ’Settings’ /’Editor’ /’Other Options’ or by setting the checkbox ’Word wrap’ . The Home and End keys position the cursor at the beginning or end of wrapped lines respectively. When setting ’Settings’ /’Editor’ /’Other Options’ and ’Home key always move to caret to first column’ , the cursor will be positioned at the beginning or end of the current line respectively, if the Home or End keys are pressed. If positioning the cursor at the beginning of the first line of the current paragraph is desired, the key combination ’Alt-Home’ is to be used. The same applies analogously for ’Alt-End’ for positioning the cursor at the end of the last line of the current paragraph.
CodeBlocks supports the block select mode within the editor. Hold the key ’ALT’ and select a region with the left mouse button and copy or paste your selection. This feature is helpful if you want to select some columns e.g. of an array and copy and paste the content.
CodeBlocks supports so called code folding. With this feature you can fold e.g. functions within the CodeBlocks editor. A folding point is marked by minus symbol in the left margin of the editor view. In the margin the beginning and the end of a folding point is visible as vertical line. If you click the minus symbol with the left mouse button the code snippet will be folded or unfolded. Via the menu ’Edit’ /’Folding’ you can select the folding. In the editor you see folded code as continous horizontal line.
CodeBlocks provides the folding feature also for preprocessor directives. To enable this feature select ’Fold preprocessor commands’ via the menu ’Settings’ /’Editor’ in the folding entry.
Another possibility is to set user defined folding points. The start of folding point is entered as comment with a opening bracket and the end is market with a comment with a closing bracket.
If you open a project in CodeBlocks the ’Search directories’ of your compiler and the project, the sources and headers of your project are parsed. In addition the keyowrds of the corresponding lexer file are parsed. The parse information is used for the auto complete feature in CodeBlocks. Please check the settings for the editor if this feature is enabled. The auto completion is accessible with the shortcut Ctrl-Space. Via the menu ’Settings’ /’Editor’ /’Syntax highlighting’ you can add user defined keywords to your lexer.
If a file is removed from disk, but is still included in the project file <project>.cbp, then this ’broken file’ will be shown a broken symbol in the project view. You should use the menu ’Remove file from project’ instead of deleting files.
In large projects with a lot of subdirectories the search for broken files can be time consuming. CodeBlocks offers with the plug-in ThreadSearch (see Listing 2.6) a simple solution for this problem. If you enter a search expression in ThreadSearch and select the option ’Project files’ or ’Workspace files’ , then ThreadSearch will parse all files that are included in a project or workspace. If a broken file is found ThreadSerch will issue an error with the missing file.
In the build options of a project, you can add the used libraries via the ’Add’ button in the ’Link libraries’ entry of the ’Linker Settings’. In doing so, you can either use the absolute path to the library or just give the name without the lib prefix and file extension.
Example
For a library called <path>\libs\lib<name>.a, just write <name>. The linker with the corresponding search paths will then include the libraries correctly.
During compiling, objects name.o are created from the sources name.c/cpp. The linker then binds the individual objects into an application name.exe or for the embedded systems name.elf. In some cases, it might be desirable to predefine the order in which the objects will be linked. In CodeBlocks, this can be achieved by assigning priorities. In the context menu ’Properties’ , you can define the priorities of a file in the Build tab. A low priority will cause the file to be linked earlier.
CodeBlocks offers ways of automatically storing projects and source files, or of creating backup copies. This feature can be activated in the menu ’Settings’ /’Environment’ /’Autosave’ . In doing so, ’Save to .save file’ should be specified as the method for creating the backup copy.
In CodeBlocks, you can choose between several ways of treating file extensions. The settings dialogue can be opened via ’Settings’ /’Files extension handling’ . You can either use the applications assigned by Windows for each file extension (open it with the associated application), or change the setting for each extensions in such a way that either a user-defined program will start (launch an external program), or the file will be opened in the CodeBlocks editor (open it inside Code::Blocks editor).
IDE CodeBlocks can be executed from the command line without a graphic interface. In such a case, there are several switches available for controlling the build process of a project. Since CodeBlocks is thus scriptable, the creation of executables can be integrated into your own work processes.
Specifies the project *.cbp filename or workspace *.workspace filename. For instance, <filename> may be project.cbp. Place this argument at the end of the command line, just before the output redirection if there is any.
Open file in Code::Blocks and optionally jump to a specific line.
Shows a help message regarding the command line arguments.
Don’t perform any file association checks (Windows only).
Don’t start a DDE server (Windows only).
Don’t start an IPC server (Linux and Mac only).
Hides the splash screen while the application is loading.
Display the debug log of the application.
Sets the shared data directory prefix.
Sets the personality to use. You can use ask as the parameter to list all available personalities.
Clean and build the project or workspace.
Build the project or workspace.
Sets target for batch build. For example --target=’Release’.
Keeps the batch log window visible after the batch build is completed.
Shows a message after the batch build is completed.
All plugins are disabled on startup.
Placed in the very last position of the command line, this may be used to redirect standard output to log file. This is not a codeblock option as such, but just a standard DOS/*nix shell output redirection.
Even if an IDE such as CodeBlocks is mainly handled by mouse, keyboard shortcuts are nevertheless a very helpful way of speeding up and simplifying work processes. In the below table, we have collected some of the available keyboard shortcuts.
This is a list of shortcuts provided by the CodeBlocks editor component. These shortcuts cannot be rebound.
Artistic Style is a source code indenter, source code formatter, and source code beautifier for the C, C++, C# programming languages. It can be used to select different styles of coding rules within CodeBlocks.
When indenting source code, we as programmers have a tendency to use both spaces and tab characters to create the wanted indentation. Moreover, some editors by default insert spaces instead of tabs when pressing the tab key, and other editors have the ability to prettify lines by automatically setting up the white space before the code on the line, possibly inserting spaces in a code that up to now used only tabs for indentation.
Since the number of space characters shown on screen for each tab character in the source code changes between editors, one of the standard problems programmers are facing when moving from one editor to another is that code containing both spaces and tabs that was up to now perfectly indented, suddenly becomes a mess to look at when changing to another editor. Even if you as a programmer take care to ONLY use spaces or tabs, looking at other people’s source code can still be problematic.
To address this problem, Artistic Style was created - a filter written in C++ that automatically re-indents and re-formats C / C++ / C# source files.
The CodeSnippets plug-in makes it possible to structure text modules and links to files according to categories in a tree view. The modules are used for storing often used files and constructs in text modules and managing them in a central place. Imagine the following situation: A number of frequently used source files are stored in different directories of the file system. The CodeSnippets window provides the opportunity to create categories, and below the categories, links to the required files. With these features, you can control the access to the files independently from where they are stored within the file system, and you can navigate quickly between the files without the need to search the whole system.
The list of text modules and links can be stored in the CodeSnippets window by right-clicking and selecting ’Save Index’ from the context menu. The file codesnippets.xml which will be created by this procedure, can then be found in the codeblocks subdirectory of your Documents and Settings\Application data directory. Under Linux, this information is stored in the .codeblocks subdirectory of your HOME directory. The CodeBlocks configuration files will be loaded during the next start-up. If you wish to save the content of CodeSnippets at a different location, select the ’Save Index As’ entry. To load this file, select ’Load Index File’ during the next start-up of CodeBlocks or include the directory in the ’Settings’ context menu under ’Snippet Folder’. The settings are saved in the corresponding file codesnippets.ini in your application data.
For including a category, use the ’Add SubCategory’ menu. A category can contain Snippets (text modules) or File Links. A text module is created via the ’Add Snippet’ command in the context menu. The content is integrated into the text module as ’New snippet’ by selecting the text passage in the CodeBlocks editor and dragging and dropping it onto the module and the properties dialog pops up. Double-clicking the newly included entry or selecting ’Edit Text’ will open an editor for the content.
Output of a text module is handled in CodeBlocks via the context menu command ’Apply’ or by dragging and dropping into the editor. Under Windows, the contents of a Snippet can also be dragged and dropped into other applications. In the CodeSnippets Browser you can copy a selected item with drag and drop to a different category.
Beyond this, text modules can be parametrised by <name> variables which can be accessed via $(name) (see Figure 2.2). The values of the variables can be retrieved in an entry field if the text module is called via the context menu command ’Apply’.
Besides the text modules, links to files can also be created. If, after having created a text module, you click the context menu command ’Properties’, then you can select the link target by clicking the ’Link target’ button. This procedure will automatically convert the text module into a link to a file. In CodeSnippets, all text modules will be marked by a T symbol, links to a file by an F symbol and urls by an U symbol. If you want to open a selected file (link) in the codesnippets view just select the context menu ’Open File’ or hold the ’Alt’ key and make a double click on the file.
With this setting, if open a link to a pdf file from the codesnippets view a pdf viewer will be started automatically. This method makes it possible for a user to access files which are spread over the whole network, such as cad data, layouts, documentations etc., with the common applications, simply via the link. The content of the codesnippets is stored in the file codesnippets.xml, the configuration is stored in the file codesnippets.ini in your application data directory. This ini file will, for example, contain the path of the file codesnippets.xml.
CodeBlocks supports the usage of different profiles. These profiles are called personalities. Starting CodeBlocks with the command line option --personality=<profile> will create a new or use an existing profile. Then the settings will not be stored in the file default.conf, but in <personality>.conf in your application data directory instead. The Codesnippets plugin will then store its settings in the file <personality>.codesnippets.ini. Now, if you load a new content <name.xml> in the Codesnippets settings via ’Load Index File’, this content will be stored in the corresponding ini file. The advantage of this method lies in the fact that in case of different profiles, different configurations for text modules and links can be managed.
The plug-in offers an additional search function for navigating between the categories and Snippets. The scope for searching Snippets, categories or Snippets and categories can be adjusted. By entering the required search expression, the corresponding entry is automatically selected in the view. Figure 2.3 shows a typical display in the CodeSnippets window.
For an efficient search in open files, CodeBlocks provides the so-called Incremental Search. This search method is initiated for an open file via the menu ’Search’ /’Incremental Search’ or by the keyboard shortcut Ctrl-I. The focus is then automatically set to the search mask of the corresponding toolbar. As soon as you begin entering the search term, the background of the search mask will be adjusted in accordance with the occurrence of the term. If a hit is found in the active editor, the respective position in the text is marked in colour. By default the current hit will be highlighted in green. This setting can be changed via ’Settings’ /’ Editor’ /’ Incremental Search’ (see Figure 2.4). Pressing the Return key induces the search to proceed to the next occurrence of the search term within the file.
If the search term cannot be found within the active file, this fact is highlighted by the background of the search mask being displayed in red.
The icons in the Incremental Search toolbar have the following meanings:
In complex software projects, where different users are involved, there is often the requirement of different tasks to be performed by different users. For this purpose, CodeBlocks offers a Todo List. This list can be opened via ’View’ /’To-Do list’ , and contains the tasks to be performed, together with their priorities, types and the responsible users. The list can be filtered for tasks, users and/or source files. A sorting by columns can be achieved by clicking the caption of the corresponding column.
If the sources are opened in CodeBlocks, a Todo can be added to the list via the context menu command ’Add To-Do item’. A comment will be added in the selected line of the source code.
When adding a To-Do, a dialogue box will appear where the following settings can be made (see Figure 2.6).
The necessity occurs frequently of transferring source code to other applications or to e-mails. If the text is simply copied, formatting will be lost, thus rendering the text very unclear. The CodeBlocks export function serves as a remedy for such situations. The required format for the export file can be selected via ’File’ /’Export’ . The program will then adopt the file name and target directory from the opened source file and propose these for saving the export file. The appropriate file extension in each case will be determined by the export format. The following formats are available.
Via the ’Search’ /’Thread Search’ menu, the appropriate plug-in can be shown or hidden as a tab in the Messages Console. In CodeBlocks, a preview can be displayed for the occurrence of a character string in a file, workspace or directory. In doing so, the list of search results will be displayed on the right-hand side of the ThreadSearch Console. By clicking an entry in the list, a preview is displayed on the left-hand side. By double-clicking in the list, the selected file is opened in the CodeBlocks editor.
ThreadSearch plugin offers the following features:
Once the plugin is installed, there are 4 ways to run a search:
To access ThreadSearch plugin configuration panel click on (see Figure 2.8):
Search in part defines the set of files that will be analysed.
If you search different terms the list will become confusing, therefore previous search results can be cleared at search begin using this option.
You can choose different modes how the the ThreadSearch window is managed. With the setting ’Message Notebook’ the ThreadSearch window will be a dockable window in the message panel. If you choose the setting ’Layout’ you will be able to undock the window from the message panel and put it somewhere else.
The view of the search results can be displayed in different ways. The setting ’List’ displays all occurrences as list. The other mode ’Tree’ gathers all occurrences within a file as a node.
The user can configure a horizontal or vertical splitting of the preview window and the output window of the search results.
The view of the search results may be sorted by path or file name.
The File Explorer Figure 2.9 is included in the FileManager plugin, and can be found in the ’Files’ tab. The composition of the File Explorer is shown in Figure 2.9.
On top you will find a field for entering the path. By clicking the button at the end of this field, the drop-down field will list a history of the past entries which can be navigated via a scroll bar. The up arrow key on the right-hand side of the field moves up the directory structure one directory.
In the ’Wildcard’ field you can enter a filter term for the file display. Leaving the field empty or entering * results in all files being displayed. Entering *.c;*.h, for example will result in solely C sources and header files being displayed. Opneing the pull-down field will, again, list a history of the last entries.
Pressing the Shift key and clicking selects a group of files or directories, pressing the Ctrl key and clicking selects multiple separate files or directories.
The following operations can be started via the context menu if one or multiple directories are selected in the File Explorer:
The following operations can be started via the context menu if one or multiple files or directories are selected in the File Explorer:
The following operations can be started via the context menu if one or multiple files are selected in the File Explorer:
User-defined functions can be specified via the menu command ’Settings’ /’Environment’ /’PowerShell’ . In the PowerShell mask, a new function which can be named at random, is created via the ’New’ button. In the ’ShellCommand Executable’ field, the executable program is stated, and in the field at the bottom of the window, additional parameters can be passed to the program. By clicking the function in the context menu or the PowerShell menu, the function is started and will then process the selected files/directories. The output is redirected to a separate shell window.
For example a menu entry in ’PowerShell’ /’SVN’ and in the context menu is created for ’SVN’. $file in this context means the file selected in the File Explorer, $mpath the selected files or directories (see Listing 3.2).
This and every subsequent command will create a submenu, in this case called ’Extensions’ /’SVN’ /’Add’ . The context menu is extended accordingly. Clicking the command in the context menu will make the SVN command add process the selected files/directories.
TortoiseSVN is a widespread SVN program with integration in the explorer. The program TortoiseProc.exe of TortoiseSVN can be started in the command line and dispalys a dialogue to collect user input. So you can perform the commands, that are available as context menu in the explorer also in the command line. Therefore you can integrate it also a shell extension in CodeBlocks. For example the command
will diff a selected file in the CodeBlocks file explorer with the SVN base. See Figure 2.10 how to integrate this command.
Example
You can use the file explorer to diff files or directories. Follow these steps:
This command will be executed using the selected files or directories as parameter. The selection is accessed via the variable $mpaths. This is an easy way to diff files or directories.
Call this executable.
Name of the file without extension.
Extension of the selected file.
Name of the file.
Name of the file without path info.
Name of the selected directory.
Name of directory without path info.
Absolute path.
Relative path of file or directory.
List of current selected files or directories.
String that is entered in a message window.
Parent directory (../).
Browse Tracker is a plug-in that helps navigating between recently opened files in CodeBlocks. The list of recent files is saved in a history. With the menu ’View’ /’Browse Tracker’ /’Clear All’ the history is cleared.
With the window ’Browsed Tabs’ you can navigate between the items of the recently opened files using the menu entry ’View’ /’Browse Tracker’ /’Backward Ed/Forward Ed’ or the shortcut Alt-Left/Alt-Right. The Browse Tracker menu is also accessible as context menu. The markers are saved in the layout file <projectName>.bmarks
A common procedure when developing software is to struggle with a set of functions which are implemented in different files. The BrowseTracks plug-in will help you solve this problem by showing you the order in which the files were selected. You can then comfortably navigate the function calls.
The plug-in allows even browse markers within each file in the CodeBlocks editor. The cursor position is memorized for every file. You can set this markers using the menu item ’View’ /’ Browse Tracker’ /’ Set BrowseMarks’ or with selecting a line with the left mouse button. A marker with † is shown in the left margin. With the menu ’View’ /’Browse Tracker’ /’Prev Mark/Next Mark’ or the shortcut Alt-up/Alt-down you can navigate through the markers within a file. If you want to navigate in a file between markers sorted by line numbers then just select the menu ’View’ /’Browse Tracker’ /’Sort BrowseMark’ .
With the ’Clear BrowseMark’ the marker in a selected line is removed. If a marker is set for a line, holding left-mouse button down for 1/4 second while pressing the Ctrl key will delete the marker for this line. Via the menu ’Clear All BrowseMarks’ or with a Ctrl-left click on any unmarked line will reset the markers within a file.
The settings of the plug-in can be configure via the menu ’Settings’ /’Editor’ /’Browse Tracker’ .
The configuration of the plug-in is stored in your application data directory in the file default.conf. If you use the personality feature of CodeBlocks the configuration is read from the file <personality>.conf.
The support of the version control system SVN is included in the CodeBlocks plugin TortoiseSVN. Via the menu ’TortoiseSVN’ /’Plugin settings’ you can configure the accessible svn commands in the tab ’Integration’ .
In the plugin settings you can configure which svn commands are accessible via the menu or the context menu. The tab integration provides the entry ’Edit main menu’ and ’Edit popup menu’ to configure these commands.
If you want to use some libraries in your application, you have to configure your project to use them. Such configuration process may be hard and annoying because each library can use custom options scheme. Another problem is that configuration differs on platforms which result in incompatibility between unix and windows projects.
LibFinder provides two major functionalities:
Searching for libraries is available under ’Plugins’ /’Library finder’ menu. It’s purpose is to detect libraries installed on your system and store the results inside LibFinder’s database (note that these results are not written into CodeBlocks project files). Searching starts with dialogue where you can provide set of directories with installed libraries. LibFinder will scan them recursively so if you’re not sure you may select some generic directories. You may even enter whole disks — in such case searching process will take more time but it may detect more libraries (see Figure 2.11).
When LibFinder scans for libraries, it uses special rules to detect presence of library. Each set of rules is located in xml file. Currently LibFinder can search for wxWidgets 2.6/2.8, CodeBlocks SDK and GLFW — the list will be extended in future.
After completing the scan, LibFinder shows the results (see Figure 2.12).
In the list you check libraries which should be stored into LibFinder’s database. Note that each library may have more than one valid configuration and settings added ealier are more likely to be used while building projects.
Below the list you can select what to do with results of previous scans:
Another option in this dialogue is ’Set up Global Variables’ . When you check this option, LibFinder will try automatically configure Global Variables which are also used to help dealing with libraries.
If you have pkg-config installed on your system (it’s installed automatically on most linux versions) LibFinder will also provide libraries from this tool. There is no need to perform scanning for them — they are automatically loaded when CodeBlocks starts.
LibFinder adds extra tab in Project Properties ’Libraries’ — this tab shows libs used in project and libs known in LibFinder. To add library into your project, select it in right pane and click < button. To remove library from project, select it on the left pane and click > button (see Figure 2.13).
You can filter libraries known to LibFinder by providing search filter. The ’Show as Tree’ checkbox allows to switch between categorized and uncategorized view.
If you want to add library which is not available in LibFinder’s database, you may use ’Unknown Library’ field. Note that you should enter library’s shortcode (which usually matches global variable name) or name of library in pkg-config. List of suggested shortcodes can be found at Global Variables. Using this option is recommended only when preparing project to be built on other machines where such library exists and is properly detected by LibFinder. You can access a global variable within CodeBlocks like:
Checking the ’Don’t setup automatically’ option will notify LibFinder that it should not add libraries automatically while compiling this project. In such case, LibFinder can be invoked from build script. Example of such script is generated and added to project by pressing ’Add manual build script’ .
Wizards will create projects that don’t use LibFinder. To integrate them with this plugin, you will have to manually update project build options. This can be easily achieved by removing all library-specific settings and adding library through ’Libraries’ tab in project properties.
Such project becomes cross-platform. As long as used libs are defined in LibFinder’s database, project’s build options will be automatically updated to match platform-specific library settings.
An application versioning plug in that increments the version and build number of your application every time a change has been made and stores it in version.h with easy to use variable declarations. Also have a feature for committing changes a la SVN style, a version scheme editor, a change log generator and more †
The idea of the AutoVersioning plugin was made during the development of a pre-alpha software that required the version info and status. Been to busy coding, without time to maintain the version number, just decided to develop a plugin that could do the job with little intervention as possible.
Here is the list of features the plugin covers summarized:
Just go to ’Project’ /’Autoversioning’ menu. A pop up window like this will appear:
When hitting yes on the ask to configure message box, the main auto versioning configuration dialog will open, to let you configure the version info of your project.
After configuring your project for auto versioning, the settings that you entered on the configuration dialog will be stored on the project file, and a version.h file will be created. For now, every time that you hit the ’Project’ /’Autoversioning’ menu the configuration dialog will popup to let you edit your project version and versioning related settings, unless you don’t save the new changes made by the plugin to the project file.
Here you just enter the corresponding version values or let the auto versioning plugin increment them for you (see Figure 2.15).
Some fields to keep track of your software status with a list of predefined values for convenience(see Figure 2.16).
Lets you edit how the plugin will increment the version values (see Figure 2.17).
Here you can set some settings of the auto versioning behavior (see Figure 2.18).
This lets you enter every change made to the project to generate a ChangesLog.txt file (see Figure 2.19).
To use the variables generated by the plugin just #include <version.h>. An example code would be like the following:
The generated header file. Here is a sample content of the file on c++ mode:
On C mode is the same as C++ but without the namespace:
This dialog is accessible from the menu ’Project’ /’Changes Log’ . Also if checked Show changes editor when incrementing version on the changes log settings, the window will open to let you enter the list of changes after a modification to the project sources or an incrementation event (see Figure 2.20).
Here is an example of the output generated by the plugin to the ChangesLog.txt file:
Based on the entries in the configuration mask, this simple plugin detects the proportions of code, commentaries and blank lines for a project. The evaluation is called via the menu command ’Plugins’ /’Code statistics’ .
This plugin makes it possible to select a term within the editor and to search for this term via the context menu ’Search at Koders’ in the [?] database. The dialogue offers the additional possibilities to of filtering for program languages and licences.
This database search will help you find source code originating from other world-wide projects of universities, consortiums and organisations such as Apache, Mozilla, Novell Forge, SourceForge and many others, which can be re-used without having to reinvent the wheel every time. Please observe the licence of the source code in each individual case.
A simple graphical interface to the GNU GProf Profiler.
This plugin makes it possible to search for symbols in objects and libraries. The options and the path for the command line program nm are defined in the Options tab.
Clicking the ’Search’ stats the search, the results of the NM program are displayed in a separate window caleld ’SymTabs Result’. The name of the objects or libraries containing the symbol are listed under the title ’NM’s Output’.
CodeBlocks differentiates between several types of variables. These types serve the purpose of configuring the environment for creating a program, and at the same of improving the maintainability and portability. Access to the CodeBlocks variables is achieved via $<name>.
CodeBlocks treats the following functionally identical character sequences inside pre-build, post-build, or build steps as variables:
Variable names must consist of alphanumeric characters and are not case-sensitive. Variables starting with a single hash sign (#) are interpreted as global user variables (see Listing 3.7 for details). The names listed below are interpreted as built-in types.
Variables which are neither global user variables nor built-in types, will be replaced with a value provided in the project file, or with an environment variable if the latter should fail.
The variables listed here are built-in variables of CodeBlocks. They cannot be used within source files.
The filename of the current workspace project (.workspace).
The name of the workspace that is displayed in tab Projects of the Management panel.
The location of the workspace directory.
The filename of the currently compiled project.
The name of the currently compiled project.
The common top-level directory of the currently compiled project.
The filename of the file opened in the currently active editor.
the directory containing the currently active file (relative to the common top level path).
The base name (without extension) of the currently active file.
The extension of the currently active file.
A string containing the names of all files in the current project.
The filename of the makefile.
The path to the currently running instance of CodeBlocks.
The ’shared’ directory of the currently running instance of CodeBlocks.
The plugins directory of the currently running instance of CodeBlocks.
The output file of a specific target.
The output directory of a specific target.
The output file’s base name (no path, no extension) of a specific target.
The output directory of the current target.
The object directory of the current target.
The name of the current target.
The output file of the current target.
The output file’s base name (no path, no extension) of the current target.
The build tool executable (compiler, linker, etc) of the current target.
The system language in plain language.
The character encoding in plain language.
Current date in the form YYYYMMDD (for example 20051228)
Current date in the form YYYY-MM-DD (for example 2005-12-28)
Timestamp in the form YYYY-MM-DD-hh.mm (for example 2005-12-28-07.15)
] Timestamp in the form YYYY-MM-DD-hh.mm.ss (for example 2005-12-28-07.15.45)
Plain language day of the week (for example ’Wednesday’)
These are identical to the preceding types, but are expressed relative to UTC.
The number of the days passed since an arbitrarily chosen day zero (January 1, 2009). Useful as last component of a version/build number.
This variable tosses a virtual coin (once per invocation) and returns 0 or 1.
A 16-bit positive random number (0-65535)
The variable are substituted through the command of the operating system.
Copy command for files.
Remove command for files.
Move command for files.
Make directory command.
Remove directory command.
Conditional evaluation will resolve to its true clause if
Conditional evaluation will resolve to its false clause if
Example
For example if you are using several platforms and you want to set different parameters depending on the operating system. In the following code the script commands of [[ ]] are evaluated and the <command> will be executed. This could be useful in a post-built step.
For maximum flexibility, you can embed scripts using the [[ ]] operator as a special case of variable expansion. Embedded scripts have access to all standard functionalities available to scrips and work pretty much like bash backticks (except for having access to CodeBlocks namespace). As such, scripts are not limited to producing text output, but can also manipulate CodeBlocks state (projects, targets, etc.).
Example with Backticks
The expression in backticks returns a list of all executables *.elf in any subdirectories. The result of this expression can be used directly by objdump. Finally the output is piped to a file named name.dis. Thus, processes can be automatted in a simple way without having to program any loops.
Example using Script
The script text is replaced by any output generated by your script, or discarded in case of a syntax error.
Since conditional evaluation runs prior to expanding scripts, conditional evaluation can be used for preprocessor functionalities. Built-in variables (and user variables) are expanded after scripts, so it is possible to reference variables in the output of a script.
inserts the title of the active project into the command line.
Access to name of the compiler executable.
Access to name of the linker executable.
Compiler flags
Linker flags
Compiler include paths
Linker include paths
Linker libraries
Source file (full name)
Source file directory without file name and file name extension.
Source file name without path info and file name extension.
Directory of executable without file name and file name extension.
File name of executable without path and file name extension.
File name extension of executable without path and file name.
Object file
Executable output file
Object Output Directory
Working as a developer on a project which relies on 3rd party libraries involves a lot of unnecessary repetitive tasks, such as setting up build variables according to the local file system layout. In the case of project files, care must be taken to avoid accidentially committing a locally modified copy. If one does not pay attention, this can happen easily for example after changing a build flag to make a release build.
The concept of global compiler variables is a unique new solution for CodeBlocks which addresses this problem. Global compiler variables allow you to set up a project once, with any number of developers using any number of different file system layouts being able to compile and develop this project. No local layout information ever needs to be changed more than once.
Global compiler variables in CodeBlocks are discriminated from per-project variables by a leading hash sign. Global compiler variables are structured; every variable consists of a name and an optional member. Names are freely definable, while some of the members are built into the IDE. Although you can choose anything for a variable name in principle, it is advisable to pick a known identifier for common packages. Thus the amount of information that the user needs to provide is minimised. The CodeBlocks team provides a list of recommended variables for known packages.
The member base resolves to the same value as the variable name uses without a member (alias).
The members include and lib are by default aliases for base/include and base/lib, respectively. However, a user can redefine them if another setup is desired.
It is generally recommended to use the syntax $(#variable.include) instead of $(#variable)/include, as it provides additional flexibility and is otherwise exactly identical in functionality (see Listing 3.12.1 and Figure 3.1 for details).
The members cflags and lflags are empty by default and can be used to provide the ability to feed the same consistent set of compiler/linker flags to all builds on one machine. CodeBlocks allows you to define custom variable members in addition to the built-in ones.
CodeBlocks will detect the most obvious cases of recursive definitions (which may happen by accident), but it will not perform an in-depth analysis of every possible abuse. If you enter crap, then crap is what you will get; you are warned now.
Examples
Defining wx.include as $(#wx)/include is redundant, but perfectly legal Defining wx.include as $(#wx.include) is illegal and will be detected by CodeBlocks Defining wx.include as $(#cb.lib) which again is defined as $(#wx.include) will create an infinite loop
All you need to do for using global compiler variables is to put them in your project! Yes, it’s that easy.
When the IDE detects the presence of an unknown global variable, it will prompt you to enter its value. The value will be saved in your settings, so you never need to enter the information twice.
If you need to modify or delete a variable at a later time, you can do so from the settings menu.
Example
The above image shows both per-project and global variables. WX_SUFFIX is defined in the project, but WX is a global user variable.
Sometimes, you want to use different versions of the same library, or you develop two branches of the same program. Although it is possible to get along with a global compiler variable, this can become tedious. For such a purpose, CodeBlocks supports variable sets. A variable set is an independent collection of variables identified by a name (set names have the same constraints as variable names).
If you wish to switch to a different set of variables, you simply select a different set from the menu. Different sets are not required to have the same variables, and identical variables in different sets are not required to have the same values, or even the same custom members.
Another positive thing about sets is that if you have a dozen variables and you want to have a new set with one of these variables pointing to a different location, you are not required to re-enter all the data again. You can simply create a clone of your current set, which will then duplicate all of your variables.
Deleting a set also deletes all variables in that set (but not in another set). The default set is always present and cannot be deleted.
As stated above, writing $(#var.include) and $(#var)/include is exactly the same thing by default. So why would you want to write something as unintuitive as $(#var.include)?
Let’s take a standard Boost installation under Windows for an example. Generally, you would expect a fictional package ACME to have its include files under ACME/include and its libraries under ACME/lib. Optionally, it might place its headers into yet another subfolder called acme. So after adding the correct paths to the compiler and linker options, you would expect to #include <acme/acme.h> and link to libacme.a (or whatever it happens to be).
This article will describe the process used in creating the nightly builds, and can be used as a guideline if you want to build CodeBlocks yourself. It is described as a sequence of actions.
In order to perform our build tasks, we will need several tools. Let’s create an ingredient list for our cooking experiments
Since the CodeBlocks developers build CodeBlocks using GCC, we might as well use that one under windows. The easiest and cleanest port is MinGW. This is the compiler distributed with CodeBlocks when you download the official package. We will stick to version 3.4.5, which works nicely.
First, a brief explanation of MinGW components:
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 CodeBlocks that came bundled with MinGW, 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. CodeBlocks just brings it along in the official versions so that the average user does not need to bother with this process.
You may need to add the bin directory of your MinGW installation to your path. An easy way to do this is with the following command at the command prompt:
For [?] a project description CodeBlocks.cbp is available. If you load this project file in CodeBlocks then you are able to build CodeBlocks from sources. All we need to do is get hold of a pre-built version CodeBlocks.
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. If you don’t have 7-zip, you can download it for free from [?].
Now, CodeBlocks 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 CodeBlocks nightly build. It also needs the mingwm10.dll. 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.
Finally, start up this new nightly build of CodeBlocks. It should discover the MinGW compiler we just installed.
In order to be able to retrieve the latest and greatest CodeBlocks sources, we need to install a Version Control System.
The CodeBlocks developers provide their sources through the version control system[?]. So, we need a client to access their svn repository of sources. A nice, easy client for Windows is [?], which is freely available. 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 for Url of Repository:
svn://svn.berlios.de/codeblocks/trunk
and leave all other settings as they are.
Now be patient while TortoiseSVN retrieves the most recent source files from the CodeBlocks repository into our local directory. Yes; all those CodeBlocks sources are coming your way!
For more info on SVN settings, see info on SVN settings. If you don’t like an Explorer integration or look for a cross-plattform client you might want to have a look at RapidSVN..
[?] is a platform abstraction that provides an API to support many things such as GUI, sockets, files, registry functionality. By using this API, you can create a platform independent program.
CodeBlocks is a wxWidgets (here after: wx) application, that means if you want to run CodeBlocks you needed the wx functionality. This can be provided in a couple of ways. It could be a .dll or a static library. CodeBlocks uses wx as a dll and 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 include the headers of the wx sources. They tell the compiler about the functionality of wx. In addition to those header files, our application needs to link to the wx 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. We already shopped for the MinGW compiler, so we have all the tools we need at hand.
Next, let’s unzip the wx sources into C:\Projects so we will end up with a wx root directory like this: C:\Projects\wxWidgets-2.8.9. Next unzip the patch into the same directory letting it overwrite files. Note that we are going to refer to the wx root directory from now on as <wxDir>
Now, we are going to build the wxWidgets. This is how we do it:
First, make sure C:\MingGW\bin is in your path, during the build some programs will be called that reside in the the MinGW\bin directory. Also, Make has to be version 3.80 or above.
Now it is time to compile wxWidgets. Open the command prompt and change to the wxWidgets directory:
We are now in the right place. We are first going to clean up the source:
Once everything is clean, we can compile wxWidgets:
This is going to take some time.
For making the debug build, follow these steps:
Well have a little look in the directory (<wxDir>\lib\gcc_dll) now. The import libraries and the dll have shown up and there should also a mswu\wx subdirectory at that position containing setup.h.
Congratulations! You have just built wxWidgets!
Let’s do some more preliminary tasks before we get to the real deal of compiling CodeBlocks.
During the build of CodeBlocks, several resources are going to be zipped in zip files. Therefore, the build process should have access to a zip.exe. We have to download that zip.exe and put it somewhere in our path. A good place is: MingW\bin.
You can download zip.exe for free from this site and this is a direct link(32bit) to the most recent version at the time of this writing.
Once downloaded, simply extract zip.exe to the appropriate location.
With this function the SVN revision of the Nightly Builts is updated in the sources. The file can be found in the main directory of the CodeBlocks sources.
Now, open the project CodeBlocks.cbp in CodeBlocks. Generate CodeBlocks by starting the build process. After the creation of CodeBlocks, the generated files with the debug information can be found in the devel subdirectory. By calling the batch file update.bat from the source directory, the files are copied to the output subdirectory and the debug information is stripped.
When generating under Linux, the following steps are necessary. In this example we assume that you are in the CodeBlocks source directory. Under Linux, the environment variable PKG_CONFIG_PATH must be set. The <prefix> directory has to contain the codeblocks.pc file.
Afterwards, configure the global variables via ’Settings’ /’Global Variables’ .
Variable cb
For the cb variable, set the base entry to the source directory of CodeBlocks.
Variable wx
For the wx variable, set the base entry to the source directory of wx (e.g.
In the CodeBlocks project, the project variable WX_SUFFIX is set to u. This means that, when generating CodeBlocks linking will be carried out against the *u_gcc_custom.dll library. The official nightly Builts of CodeBlocks will be linked against gcc_cb.dll. In doing so, the layout is as follows.
The <VENDOR> variable is set in the configuration file compiler.gcc. To ensure, that a distinction is possible between the officially generated CodeBlocks and those generated by yourself, the default setting VENDOR=custom should never be changed.
Afterwards create the workspace ContribPlugins.cbp via ’Project’ /’Build workspace’ . Then execute update.bat once more.
Variable wx bei globalen Variablen konfigurieren. Configure the wx variable with the global variables.
debug CodeBlocks. Start CodeBlocks in the output directory and load CodeBlocks.cbp as the project. Then set the breakpoint and start with ’Debug and Run’ (f8).
This brings us to the last preliminary task. The CodeBlocks code can be divided into 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 CodeBlocks project file which you can find at: <cbDir>\src\CodeBlocks.cbp. Our CodeBlocks master directory is from now one mentioned as <cbDir>, by the way. A workspace is something that groups several projects together. To build the contrib plug-ins, they can be found at
But, let’s create a workspace containing everything. 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 :
We will use this workspace to build all of CodeBlocks.
Finally we have arrived at the final step; our final goal. Run the CodeBlocks executable from your nightly build download. Choose Open from the File menu and browse for our above created workspace, and open it up. Be a little patient while CodeBlocks is parsing everything, and CodeBlocks will ask us for 2 global variables, these global variables will tell the nightly CodeBlocks where it can find wxWidgets (remember : header files and import libraries) and where it can find .... CodeBlocks, this is needed for the contrib plug-ins, they need to know (as for any user created plug-in) where the sdk (CodeBlocks header files) are. These are the values in our case :
Now go to the Project Menu and choose (re)build workspace, and off you go. Watch how CodeBlocks is building CodeBlocks.
Once the build is complete, open up a console in <cbDir>/src and run the command update.bat. This will transfer all built deliverables from <cbDir>/src/devel to <cbDir>/src/output. In addition, it will strip out all debugging symbols. This step is very important - never ever forget it.
Now you can copy the wx dll in both that output and the devel directory.
Then you can close CodeBlocks. That was the downloaded nightly remember?
Time to test it. In the output directory, start up the CodeBlocks.exe. If everything went well, you’ll have your very own home-built CodeBlocks running.