Difference between revisions of "在Windows上由源代码开始安装Code::Blocks"

From Code::Blocks
 
(4 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
旧的Code::Blocks RC2版本不支持在RC2之后的发布版本才增加的全局编译器变量,并且不能读取由RC2之后版本生产的项目文件。要安装Code::Blocks,你需要一个比RC2更新的版本,例如''8.02''或者是任意一个''当日最新版本(nightly builds)''该版本可以在论坛中[/index.php?board=20.0 搜索]来获取。
 
旧的Code::Blocks RC2版本不支持在RC2之后的发布版本才增加的全局编译器变量,并且不能读取由RC2之后版本生产的项目文件。要安装Code::Blocks,你需要一个比RC2更新的版本,例如''8.02''或者是任意一个''当日最新版本(nightly builds)''该版本可以在论坛中[/index.php?board=20.0 搜索]来获取。
  
=== MinGW compiler ===
+
=== MinGW编译器 ===
  
At the present time, Code::Blocks only compiles successfully with the MinGW compiler (or any other gcc for that matter). You will need a complete, working [[MinGW installation]].
+
目前,Code::Blocks仅能使用MinGW编译器(或其它的gcc编译器)来编译。你需要完成[[安装MinGW]]并使工作工作的。
  
Since November 2007 MinGW-GCC 4.2.1
+
自20007年11月的MinGW-GCC 4.2.1之后的版本都可用
  
 
=== wxWidgets ===
 
=== wxWidgets ===
Line 17: Line 17:
 
[http://wxwidgets.org/ wxWidgets.org]
 
[http://wxwidgets.org/ wxWidgets.org]
  
Code::Blocks uses
+
Code::Blocks用户
* since 19 July 2008 wxWidgets 2.8.8 <br/>Download: [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.8.zip wxMSW-2.8.8.zip]
+
* 2008年7月19之后的wxWidgets 2.8.8 <br/>下载: [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.8.zip wxMSW-2.8.8.zip]
  
* since 28 November 2007 wxWidgets 2.8.7 <br/>Download: [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.7.zip wxMSW-2.8.7.zip]
+
* 2007年11月28之后的wxWidgets 2.8.7 <br/>下载: [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.7.zip wxMSW-2.8.7.zip]
  
* since November 2007 wxWidgets 2.8.6 <br/>Download: [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.6.zip wxMSW-2.8.6.zip]
+
* 2007年11月之后的wxWidgets 2.8.6 <br/>下载: [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.6.zip wxMSW-2.8.6.zip]
  
* since May 2007 wxWidgets 2.8.4<br/>Download: [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.4.zip wxMSW-2.8.4.zip]
+
* 2007年5月之后的wxWidgets 2.8.4<br/>下载: [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.4.zip wxMSW-2.8.4.zip]
  
For latest infos check forum: [/index.php?topic=3299.0 Important changes to the nightly builds]
+
最新版本信息可以在论坛查找: [/index.php?topic=3299.0 当日最新版本的重要更新]
  
  
You do ''not'' need MSYS (''in fact, if you have MSYS, make sure it is not in your PATH when building wxWidgets'').
+
你并''''需要MSYS (''实际上,如果你已经安装了MSYS,那么再构建wxWidgets时要确保其不在你的路径中'')
  
=== SVN client ===
+
=== SVN客户端 ===
  
In order to check out the Code::Blocks sources you will need a SVN client.
+
为了要获取Code::Blocks的源代码你需要一个SVN客户端。
For convenience, it is recommended that you install [http://tortoisesvn.net/downloads 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 svn command-line client] equally well.
+
方便起见,推荐你安装[http://tortoisesvn.net/downloads TortoiseSVN],它用起来更为舒适。然而,如果你那些在你的资源管理器添加菜单的程序很憎恨的话,那么你也可以使用[http://subversion.tigris.org/project_packages.html svn 命令行客户端]
  
 
It is generally a good idea to install the command-line client (and adding it to PATH) even if you use TortoiseSVN for convenience. The <tt>autorevision</tt> tool which is used during the build of Code::Blocks makes use of the <tt>svn</tt> binary if it is available. This is preferrable to the manual parsing of the entries file that is used as fallback.
 
It is generally a good idea to install the command-line client (and adding it to PATH) even if you use TortoiseSVN for convenience. The <tt>autorevision</tt> tool which is used during the build of Code::Blocks makes use of the <tt>svn</tt> binary if it is available. This is preferrable to the manual parsing of the entries file that is used as fallback.

Latest revision as of 02:03, 29 August 2008

先决条件

RC2用户注意

旧的Code::Blocks RC2版本不支持在RC2之后的发布版本才增加的全局编译器变量,并且不能读取由RC2之后版本生产的项目文件。要安装Code::Blocks,你需要一个比RC2更新的版本,例如8.02或者是任意一个当日最新版本(nightly builds)该版本可以在论坛中[/index.php?board=20.0 搜索]来获取。

MinGW编译器

目前,Code::Blocks仅能使用MinGW编译器(或其它的gcc编译器)来编译。你需要完成安装MinGW并使工作工作的。

自20007年11月的MinGW-GCC 4.2.1之后的版本都可用

wxWidgets

wxWidgets.org

Code::Blocks用户

最新版本信息可以在论坛查找: [/index.php?topic=3299.0 当日最新版本的重要更新]


你并需要MSYS (实际上,如果你已经安装了MSYS,那么再构建wxWidgets时要确保其不在你的路径中)。

SVN客户端

为了要获取Code::Blocks的源代码你需要一个SVN客户端。 方便起见,推荐你安装TortoiseSVN,它用起来更为舒适。然而,如果你那些在你的资源管理器添加菜单的程序很憎恨的话,那么你也可以使用svn 命令行客户端

It is generally a good idea to install the command-line client (and adding it to PATH) even if you use TortoiseSVN for convenience. The autorevision tool which is used during the build of Code::Blocks makes use of the svn binary if it is available. This is preferrable to the manual parsing of the entries file that is used as fallback.


Please do note that working copies checked out with the 1.4 version of Subversion are no longer compatible with earlier versions (Subversion will transparently update existing repositories).

The builtin fallback mechanism in autorevision has been updated to the new 1.4 format and will no longer work with the old format.
Therefore, if you use a Subversion client from the 1.0-1.3 line, you must put the commandline tool into PATH for a successful build.
If you use Subversion 1.4, then it is good practice nevertheless, but you can do without, too.

zip.exe

You'll also need a working 'zip' program. If you have the version listed on our tools page, you'll be fine.

The zip program coming with cygwin will not work properly. You do not need WinZip.

Make sure the zip binary is in your PATH so the update.bat script will be able to find it (alternatively, you can edit the batch file, setting the ZIPCMD variable to something else).

The easiest way is to put zip.exe into bin inside your MinGW installation directory (that folder is normally in the path).

Code::Blocks sources

You will also (obviously) need the Code::Blocks sources.

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

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.

remark: If you want to use wxWidgets not only for building Code::Blocks, but also for writing wxWidgets programs, and if you want to use the debugger in those programs, you have to compile a debug build of wxWidgets as well. Use the same commands as for the release build, but replace "release" by "debug".

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 lib\gcc_dll\wxmsw28u_gcc_custom.dll from the wxWidgets directory to the src\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 src\update.bat (located in the root source directory). This will pack the resource files and copy libraries and plugins to their correct locations. The stripped ("production") executable is found in output together with all libraries and data files. If you want a version with debug symbols instead (caution: huge size!), use the one found in the devel folder.
Congratulations, you own a freshly built version of Code::Blocks!

For future updates, go into the Code::Blocks root directory and run svn update (or use TurtoiseSVN to the same effect).
Then open and build the project as described before (and any contrib plugins that you wish to use), and re-run src\update.bat.

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).
When you open the contrib plugins workspace, you will be asked to define the $(#cb) global compiler variable. This is the path that contains the sdk folder normally this is codeblocks\src. The build process uses this information to place the plugins and data files into the correct place. Enter the location of the Code::Blocks sources in the same way as for the $(#wx) variable earlier.

Don't forget to run update.bat again after building the contrib plugins.

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 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 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 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.