Building an Non-Unicode Win32 Code::Blocks

From Code::Blocks


Prerequisites

Working Code::Blocks

Code::Blocks Source Code

Non-Unicode build of wxWidgets

GnuWin32 sed.exe

http://gnuwin32.sourceforge.net/packages.html

Needed files

sed script file and batch files

ANSI.sed

s/<Variable name="WX_SUFFIX" value="u" \/>/<Variable name="WX_SUFFIX" value="" \/>/g
s/<Add option="-DwxUSE_UNICODE" \/>$/<Add option="-DwxUSE_UNICODE=0" \/>$/g
s/<Add option="-DwxUSE_UNICODE=1" \/>$/<Add option="-DwxUSE_UNICODE=0" \/>$/g

sed-ANSI-out.bat

setlocal
REM Set to the folder containing the SED script
set SEDFOLDER=%CD%
REM Set to the sed script file name
set SEDFILE=ANSI.sed

REM set to the Top Code::Blocks folder
set CBFOLDER=%CD%\codeblocks

cd %CBFOLDER%\src
sed --separate --file=%SEDFOLDER%\%SEDFILE% CodeBlocks.cbp > CodeBlocks-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\AutoVersioning
sed --separate --file=%SEDFOLDER%\%SEDFILE% AutoVersioning.cbp > AutoVersioning-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\BrowseTracker
sed --separate --file=%SEDFOLDER%\%SEDFILE% BrowseTracker.cbp > BrowseTracker-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\byogames
sed --separate --file=%SEDFOLDER%\%SEDFILE% byogames.cbp > byogames-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\cb_koders
sed --separate --file=%SEDFOLDER%\%SEDFILE% cb_koders.cbp > cb_koders-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\codesnippets
sed --separate --file=%SEDFOLDER%\%SEDFILE% codesnippets.cbp > codesnippets-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\codestat
sed --separate --file=%SEDFOLDER%\%SEDFILE% codestat.cbp > codestat-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\copystrings
sed --separate --file=%SEDFOLDER%\%SEDFILE% copystrings.cbp > copystrings-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\devpak_plugin
sed --separate --file=%SEDFOLDER%\%SEDFILE% DevPakPlugin.cbp > DevPakPlugin-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\dragscroll
sed --separate --file=%SEDFOLDER%\%SEDFILE% dragscroll.cbp > dragscroll-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\envvars
sed --separate --file=%SEDFOLDER%\%SEDFILE% envvars.cbp > envvars-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\headerfixup
sed --separate --file=%SEDFOLDER%\%SEDFILE% headerfixup.cbp > headerfixup-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\help_plugin
sed --separate --file=%SEDFOLDER%\%SEDFILE% help-plugin.cbp > help-plugin-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\keybinder
sed --separate --file=%SEDFOLDER%\%SEDFILE% keybinder.cbp > keybinder-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\lib_finder
sed --separate --file=%SEDFOLDER%\%SEDFILE% lib_finder.cbp > lib_finder-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\profiler
sed --separate --file=%SEDFOLDER%\%SEDFILE% cbprofiler.cbp > cbprofiler-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\regex_testbed
sed --separate --file=%SEDFOLDER%\%SEDFILE% RegExTestbed.cbp > RegExTestbed-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\source_exporter
sed --separate --file=%SEDFOLDER%\%SEDFILE% Exporter.cbp > Exporter-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\symtab
sed --separate --file=%SEDFOLDER%\%SEDFILE% symtab.cbp > symtab-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\ThreadSearch
sed --separate --file=%SEDFOLDER%\%SEDFILE% ThreadSearch.cbp > ThreadSearch-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\wxSmith
sed --separate --file=%SEDFOLDER%\%SEDFILE% wxSmith.cbp > wxSmith-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\wxSmithContribItems
sed --separate --file=%SEDFOLDER%\%SEDFILE% wxSmithContribItems.cbp > wxSmithContribItems-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\HexEditor
sed --separate --file=%SEDFOLDER%\%SEDFILE% HexEditor.cbp > HexEditor-ANSI.cbp

cd %CBFOLDER%\src\plugins\codecompletion
sed --separate --file=%SEDFOLDER%\%SEDFILE% cctest.cbp > cctest-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\wxContribItems
sed --separate --file=%SEDFOLDER%\%SEDFILE% wxContribItems.cbp > wxContribItems-ANSI.cbp

cd %CBFOLDER%\src\plugins\contrib\wxSmithAui
sed --separate --file=%SEDFOLDER%\%SEDFILE% wxSmithAui.cbp > wxSmithAui-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\Cccc
sed --separate --file=%SEDFOLDER%\%SEDFILE% Cccc.cbp > Cccc-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\CppCheck
sed --separate --file=%SEDFOLDER%\%SEDFILE% CppCheck.cbp > CppCheck-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\Cscope
sed --separate --file=%SEDFOLDER%\%SEDFILE% Cscope.cbp > Cscope-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\DoxyBlocks
sed --separate --file=%SEDFOLDER%\%SEDFILE% DoxyBlocks.cbp > DoxyBlocks-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\EditorConfig
sed --separate --file=%SEDFOLDER%\%SEDFILE% EditorConfig.cbp > EditorConfig-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\EditorTweaks
sed --separate --file=%SEDFOLDER%\%SEDFILE% EditorTweaks.cbp > EditorTweaks-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\FileManager
sed --separate --file=%SEDFOLDER%\%SEDFILE% FileManager.cbp > FileManager-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\FortranProject
sed --separate --file=%SEDFOLDER%\%SEDFILE% FortranProject_cbsvn.cbp > FortranProject_cbsvn-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\IncrementalSearch
sed --separate --file=%SEDFOLDER%\%SEDFILE% IncrementalSearch.cbp > IncrementalSearch-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\MouseSap
sed --separate --file=%SEDFOLDER%\%SEDFILE% MouseSap.cbp > MouseSap-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\NassiShneiderman
sed --separate --file=%SEDFOLDER%\%SEDFILE% NassiShneiderman.cbp > NassiShneiderman-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\ReopenEditor
sed --separate --file=%SEDFOLDER%\%SEDFILE% ReopenEditor.cbp > ReopenEditor-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\rndgen
sed --separate --file=%SEDFOLDER%\%SEDFILE% rndgen.cbp > rndgen-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\SmartIndent
sed --separate --file=%SEDFOLDER%\%SEDFILE% SmartIndent.cbp > SmartIndent-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\SpellChecker
sed --separate --file=%SEDFOLDER%\%SEDFILE% SpellChecker.cbp > SpellChecker-ANSI.cbp
 
cd %CBFOLDER%\src\plugins\contrib\ToolsPlus
sed --separate --file=%SEDFOLDER%\%SEDFILE% ToolsPlus.cbp > ToolsPlus-ANSI.cbp
 
cd %CBFOLDER%\src\tools\cb_share_config
sed --separate --file=%SEDFOLDER%\%SEDFILE% cb_share_config.cbp > cb_share_config-ANSI.cbp
 
cd %CBFOLDER%\src\tools\CBLauncher
sed --separate --file=%SEDFOLDER%\%SEDFILE% CBLauncher.cbp > CBLauncher-ANSI.cbp

cd %CBFOLDER%\src\tools\Addr2LineUI
sed --separate --file=%SEDFOLDER%\%SEDFILE% Addr2LineUI.cbp > Addr2LineUI-ANSI.cbp

PAUSE

Code::Blocks workspace file for Non-Unicode Build

ContribPlugins-ANSI.workspace

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_workspace_file>
	<Workspace title="All contrib plugins">
		<Project filename="tools/cb_share_config/cb_share_config-ANSI.cbp" />
		<Project filename="tools/CBLauncher/CbLauncher-ANSI.cbp" />
		<Project filename="tools/Addr2LineUI/Addr2LineUI-ANSI.cbp" />
		<Project filename="plugins/codecompletion/cctest-ANSI.cbp" />
		<Project filename="plugins/contrib/wxContribItems/wxContribItems-ANSI.cbp" />
		<Project filename="plugins/contrib/wxSmith/wxSmith-ANSI.cbp" />
		<Project filename="plugins/contrib/wxSmithContribItems/wxSmithContribItems-ANSI.cbp">
			<Depends filename="plugins/contrib/lib_finder/lib_finder-ANSI.cbp" />
			<Depends filename="plugins/contrib/wxSmith/wxSmith-ANSI.cbp" />
		</Project>
		<Project filename="plugins/contrib/wxSmithAui/wxSmithAui-ANSI.cbp">
			<Depends filename="plugins/contrib/wxSmith/wxSmith-ANSI.cbp" />
		</Project>
		<Project filename="plugins/contrib/AutoVersioning/AutoVersioning-ANSI.cbp" active="1" />
		<Project filename="plugins/contrib/BrowseTracker/BrowseTracker-ANSI.cbp" />
		<Project filename="plugins/contrib/byogames/byogames-ANSI.cbp" />
		<Project filename="plugins/contrib/cb_koders/cb_koders-ANSI.cbp" />
		<Project filename="plugins/contrib/Cccc/Cccc-ANSI.cbp" />
		<Project filename="plugins/contrib/codesnippets/codesnippets-ANSI.cbp" />
		<Project filename="plugins/contrib/codestat/codestat-ANSI.cbp" />
		<Project filename="plugins/contrib/copystrings/copystrings-ANSI.cbp" />
		<Project filename="plugins/contrib/CppCheck/CppCheck-ANSI.cbp" />
		<Project filename="plugins/contrib/Cscope/Cscope-ANSI.cbp" />
		<Project filename="plugins/contrib/devpak_plugin/DevPakPlugin-ANSI.cbp" />
		<Project filename="plugins/contrib/DoxyBlocks/DoxyBlocks-ANSI.cbp" />
		<Project filename="plugins/contrib/dragscroll/dragscroll-ANSI.cbp" />
		<Project filename="plugins/contrib/EditorConfig/EditorConfig-ANSI.cbp" />
		<Project filename="plugins/contrib/EditorTweaks/EditorTweaks-ANSI.cbp" />
		<Project filename="plugins/contrib/envvars/envvars-ANSI.cbp" />
		<Project filename="plugins/contrib/FileManager/FileManager-ANSI.cbp" />
		<Project filename="plugins/contrib/FortranProject/FortranProject_cbsvn-ANSI.cbp" />
		<Project filename="plugins/contrib/headerfixup/headerfixup-ANSI.cbp" />
		<Project filename="plugins/contrib/help_plugin/help-plugin-ANSI.cbp" />
		<Project filename="plugins/contrib/HexEditor/HexEditor-ANSI.cbp" />
		<Project filename="plugins/contrib/IncrementalSearch/IncrementalSearch-ANSI.cbp" />
		<Project filename="plugins/contrib/keybinder/keybinder-ANSI.cbp" />
		<Project filename="plugins/contrib/lib_finder/lib_finder-ANSI.cbp">
			<Depends filename="plugins/contrib/wxContribItems/wxContribItems-ANSI.cbp" />
		</Project>
		<Project filename="plugins/contrib/MouseSap/MouseSap-ANSI.cbp" />
		<Project filename="plugins/contrib/NassiShneiderman/NassiShneiderman-ANSI.cbp" />
		<Project filename="plugins/contrib/profiler/cbprofiler-ANSI.cbp" />
		<Project filename="plugins/contrib/regex_testbed/RegExTestbed-ANSI.cbp" />
		<Project filename="plugins/contrib/ReopenEditor/ReopenEditor-ANSI.cbp" />
		<Project filename="plugins/contrib/rndgen/rndgen-ANSI.cbp" />
		<Project filename="plugins/contrib/SmartIndent/SmartIndent-ANSI.cbp" />
		<Project filename="plugins/contrib/source_exporter/Exporter-ANSI.cbp" />
		<Project filename="plugins/contrib/SpellChecker/SpellChecker-ANSI.cbp" />
		<Project filename="plugins/contrib/symtab/symtab-ANSI.cbp" />
		<Project filename="plugins/contrib/ThreadSearch/ThreadSearch-ANSI.cbp">
			<Depends filename="plugins/contrib/wxContribItems/wxContribItems-ANSI.cbp" />
		</Project>
		<Project filename="plugins/contrib/ToolsPlus/ToolsPlus-ANSI.cbp" />
	</Workspace>
</CodeBlocks_workspace_file>

Steps to modify Code::Blocks projects for Non-Unicode Build

Save the ANSI.sed script file to the folder above or in the Code::Blocks source.

  1. I save mine above the codeblocks folder that contains the Code::Blocks source.

Save the sed-ANSI-out.bat batch file to the folder above or in the Code::Blocks source

Edit the sed-ANSI-out.bat batch file so SEDFOLDER and CBFOLDER are set right

  1. SEDFOLDER needs to be the full path to the folder holding ANSI.sed script file.
  2. CBFOLDER needs to be the full path to the folder holding the Code::Blocks source.

Save the ContribPlugins-ANSI.workspace workspace file

  1. Save it in the folder that contains ContribPlugins.workspace normally the src folder.

Run the sed-ANSI-out.bat batch file

Use Codeblocks to Compile the project and workspace

  1. Compile CodeBlocks-ANSI.cbp
  2. Compile ContribPlugins-ANSI.workspace

Post Questions to this forum thread

  1. /index.php/topic,9258.msg66095.html#msg66095

ANSI Build

DEPRECATION WARNING:

As of February 2006, the official default build for Code::Blocks is Unicode (see above). Although ANSI builds are technically possible, we discourage their use unless there is a good reason.
Support for ANSI builds is likely to be dropped after Version 1.0 is out.

There is hardly any good argument against using a Unicode build if your OS supports Unicode, even if you do not understand any other language than English, as a Unicode version guarantees that it will be able to work with whatever languages you may possibly encounter in the future -- at a very reasonable cost.

However, if you absolutely don't care about Unicode or if you are bound to use Windows 95, then you may want to build an ANSI version nevertheless.

Compile wxWidgets in ANSI mode

After unpacking the zip file to a directory of your choice, open a cmd prompt, and navigate to the folder build/msw inside the wxWidgets folder. Use the following commands to compile wxWidgets

set path=c:\mingw\bin;c:\mingw\mingw32\bin
mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 clean
mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0

This assumes your MinGW installation is in C:\mingw. Use a different path if you installed MinGW somewhere else.

You will see a lot of warning messages during compilation. Don't worry, this is normal, you are compiling wxWidgets. The build process may take 10-30 minutes, depending on your computer's speed.

Optional:

To reduce the size of your wxWidgets library, you can disable features which are not used by Code::Blocks. However, you should not do this unless you know what you are doing. You have to delete the generated setup.h from lib/gcc_dll/msw/wx before building, because your changes to include/wx/msw will otherwise not be honoured.

Compile Code::Blocks

Open the project CodeBlocks.cbp. You will be prompted to define the global variable $(#wx) if you have not used it before. Enter the location where you unpacked wxWidgets.

Important: The project file is set to compile an Unicode version of Code::Blocks by default. To make an ANSI build, you have to make the following two changes to build options before compiling: 1. In the "Compiler" tab, under "#defines", remove the entry wxUSE_UNICODE. 2. Under "Custom variables", set the variable WX_SUFFIX to empty (default value: u).

Hit the blue gear and lean back. Compilation may take 3-5 minutes, depending on the speed of your computer.

After the compilation has finished, copy wxmsw28u_gcc_custom.dll from lib\gcc_dll inside the wxWidgets directory to the devel directory inside the Code::Blocks source folder (it will also work if you keep a copy of that library in your Windows folder or anywhere in your system path, but this is generally not recommended because you can get into dll hell). Run update.bat (located in the root source directory). This will pack the resource files and copy libraries and plugins to their correct locations. The location of executable is src\output in C::B tree. From here you'll not need the nightly build anymore.

One little note for svn updates and rebuilds : just go into the codeblocks root directory and do svn update (or use Turtoise svn).

Then run the src/output/codeblocks.exe, reload project, build it, reload plugins workspace, build it, quit codeblocks and re-run update.bat. You'll have an up-to-date C::B in 3 minutes !

Install Code::Blocks

Copy the folder output to where you want Code::Blocks to reside.

Compile contributed (or your own) plugins

The workspace file ContribPlugins.workspace contains the project files for all contributed plugins. Open that workspace and compile the plugins which you would like to use (or select "Build Workspace" from the context menu if you want them all). Don't forget to run update.bat again after building the contrib plugins.

Note that the Nassi Shneiderman plugin (part of the contrib plugins) has a dependency on boost which is needed to compile this plugin. Boost does not need to be compiled therefore.