Difference between revisions of "Installing Code::Blocks from source on Windows"

From Code::Blocks
Line 15: Line 15:
 
[http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.6.2.zip Download wxWidgets 2.6.2 from Sourceforge].
 
[http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.6.2.zip Download wxWidgets 2.6.2 from Sourceforge].
  
You can also use the more recent wxWidgets-2.6.3, but then you need to install the '''patch 2 for 2.6.3''' over it; all this available [http://www.wxWidgets.org Here].
+
You can also use the more recent wxWidgets-2.6.3, but then you need to install the '''patch 2 for 2.6.3''' over it; all this is available [http://www.wxWidgets.org here].
  
 
You will also (obviously) need the Code::Blocks sources. It is recommended that you install  
 
You will also (obviously) need the Code::Blocks sources. It is recommended that you install  
[http://tortoisesvn.tigris.org/download.html TortoiseSVN]on your machine, as this is a lot more comfortable. However, if you get a bad feeling when some program is messing with your Explorer menu, then you can use the [http://subversion.tigris.org/project_packages.html commandline client of svn], it works just fine.
+
[http://tortoisesvn.tigris.org/download.html TortoiseSVN] on your machine, as this is a lot more comfortable. However, if you get a bad feeling when some program is messing with your Explorer menu, then you can use the [http://subversion.tigris.org/project_packages.html commandline client of svn], it works just fine.
  
 
Using ''TortoiseSVN'', make a folder where you want to store the sources, right-click on the folder, and select "SVN Checkout...".
 
Using ''TortoiseSVN'', make a folder where you want to store the sources, right-click on the folder, and select "SVN Checkout...".
Line 64: Line 64:
 
One little note for svn updates and rebuilds : just go into the codeblocks root directory and do '''svn update''' (or use Turtoise svn).
 
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/codeblock.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 !
+
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 ====
 
==== Install Code::Blocks ====
Line 108: Line 108:
 
After the compilaton has finished, copy wxmsw26u_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 [http://en.wikipedia.org/wiki/DLL_hell dll hell] ).
 
After the compilaton has finished, copy wxmsw26u_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 [http://en.wikipedia.org/wiki/DLL_hell 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.
 
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 anymore the nighty build.
+
The location of executable is src\output in C::B tree. From here you'll not need the nighty 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).
 
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/codeblock.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 !
+
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 ====
 
==== Install Code::Blocks ====

Revision as of 01:42, 13 July 2006


Prerequisites

Note for RC2 users

The older Code::Blocks RC2 does not support global compiler variables which were added after RC2 was released and is unable to read project files generated with post-RC2 versions. To build Code::Blocks, you need a post-RC2 build, such as any of the nightly builds obtainable by [/index.php?board=20.0 searching the forum].

Code::Blocks officially supports wxWidgets 2.6 (although you might be able to build with other releases). At the present time, Code::Blocks only compiles successfully with the MinGW compiler. You need a complete, working MinGW installation.

You do not need MSYS (in fact, if you have MSYS, make sure it is not in your PATH when building wxWidgets).

Download wxWidgets 2.6.2 from Sourceforge.

You can also use the more recent wxWidgets-2.6.3, but then you need to install the patch 2 for 2.6.3 over it; all this is available here.

You will also (obviously) need the Code::Blocks sources. It is recommended that you install TortoiseSVN on your machine, as this is a lot more comfortable. However, if you get a bad feeling when some program is messing with your Explorer menu, then you can use the commandline client of svn, it works just fine.

Using TortoiseSVN, make a folder where you want to store the sources, right-click on the folder, and select "SVN Checkout...".

In the top box, enter svn://svn.berlios.de/codeblocks/trunk and hit the OK button.

Using svn, you have to open a command prompt ("DOS Window"). Make a folder, change directory, and run svn:

 mkdir codeblocks-head
 cd codeblocks-head
 svn checkout svn://svn.berlios.de/codeblocks/trunk

You'll need also the 'zip.exe' packer program, found here : http://www.info-zip.org/ Only the command-line zip.exe is needed; you must install it somewhere in your PATH. C:\windows\system32 is a good place for the file.

Building

Unicode Build

Compile wxWidgets in Unicode 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 USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1  clean
 mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1

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). Enter the location where you unpacked wxWidgets.

Hit the blue gear and lean back. Compilation may take 3-5 minutes, depending on the speed of your computer. After the compilaton has finished, copy wxmsw26u_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 anymore the nighty build.

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.

ANSI Build

Note: Code::Blocks is now built in Unicode mode by default (see above). However, if you don't care about Unicode or if you use an old Windows version that does not support Unicode, then you might 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 USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=0 clean
 mingw32-make -f makefile.gcc USE_XRC=1 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 compilaton has finished, copy wxmsw26u_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 nighty 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.

Provided by Thomas Denk Small edits by Max