Difference between revisions of "Zh/Documentation/Building Guide/Building on Windows"

From Apache OpenOffice Wiki
Jump to: navigation, search
(setting the enviroment)
(starting the build)
Line 306: Line 306:
 
来设定建制的环境.
 
来设定建制的环境.
  
== starting the build ==
+
== 开始建制 ==
Build the software by typing the following in <code>$SRC_ROOT</code><ref name="Foot8">{{Template:Documentation/Note|You can also run:
+
请在根目录下输入以下来建制<code>$SRC_ROOT</code><ref name="Foot8">{{Template:Documentation/Note|你也可以运行:
 
<pre>make</pre>
 
<pre>make</pre>
but GNU/make will just start dmake. You can also run the following in the <code>instetoo_native</code> module:
+
但是 GNU/make 仅仅会启动 dmake. 你也可以在instetoo_native模块下运行:
 
<pre>build --all</pre>
 
<pre>build --all</pre>
For details run:
+
有关详细信息,请运行:
 
<pre>build --help</pre>}}</ref>:
 
<pre>build --help</pre>}}</ref>:
 
  dmake
 
  dmake
  
The building procedure will take at least an hour (on a 3 GHz Quad-Core with 8GB RAM).
+
建制过程至少需要一个小时(3GHz,4核,8G内存).
  
There are some special things in the way how OOo builds its modules. Every module has an “output” folder (with some subfolders for the different kinds of generated output) that is created the first time a build is done in the module. The name of this folder is “wntmsci10.pro” for builds with MSVC++2003, “wntmsci11.pro” for builds with MSVC++2005 and "wntmsci12.pro" for builds with MSVC++2008 (for the meaning of the "pro" extension see below). After a successful build of a module some of the generated files are copied to the output folder of the “solver” module by executing a tool called “deliver” (this is automatically called by build --all for each of the modules). Other modules will take these “delivered” files (header files, libraries etc.) to resolve their dependencies. The content of the solver module will also be used to pack the installation sets in the final step.
+
OOo在建制其模块过程中有很多特别的东西,每个模块在它第一次建制过程中都有一个“输出”文件夹(输出生成的一些子文件夹)生成.通过MSVC++2003建制的文件夹名字是“wntmsci10.pro”,在MSVC++2005和MSVC++2008建制下该文件夹名字是“wntmsci12.pro”.成功建制一个模块之后一些生成的文件通过执行一个名为“deliver”的工具(自动在建制每一个模块中执行)复制到一个命名为“solver”模块输出文件夹中.其他的模块将使用这些“deloverd”文件(头文件,库...)来解决他们之间的依赖;solver模块的内容页将被用来包装最后的安装步骤.
  
{{Template:Documentation/Tip|Using some not quite latest cygwin releases (1.5.18/1.5.19) can lead to tcsh freezing in places - the build will appear to hang. You can fix this by running ''ls /proc/$nnn/fd'' where $nnn is the number of the process. Or just run
+
{{Template:Documentation/Tip|使用一些不是最新版的cygwin(1.5.18/1.5.19)将导致建制挂起,你可以在$nnn是运行的进程号处运行ls /proc/$nnn/fd,或者运行:
 
<pre>ls /proc/*/fd</pre>
 
<pre>ls /proc/*/fd</pre>
to "unhang" the process. See {{Bug|51560}} for more info...}}
+
“取消挂起”的过程详细信息,请参阅参考51560}}
  
  
= Partial Builds =
+
= 部分建制 =
There are two ways to do partial builds:
+
有两种部分建制的方法:
* compatible
+
* 兼容的
* incompatible
+
* 不兼容的
Only do compatible partial builds if you know exactly what you are doing.
+
如果你清楚你正在干什么那么可以选择兼容模式;
{{Documentation/Note|For more information, see [[Compatible Builds]].}}
+
{{Documentation/Note|更多的信息,请看兼容模式建制 [[Compatible Builds]].}}
 +
 
 
== rebuilding from a module (incompatible build) ==
 
== rebuilding from a module (incompatible build) ==
  

Revision as of 14:00, 19 February 2013

Template:Documentation/建制指导 TOC

概述

Template:Documentation/Windows

为了能够建制 OpenOffice.org我们需要Cygwin这个工具 , 这是一个模拟一个完整的Unix命令环境的 Windows 程序.为了能够使用它,你需要熟悉命令行, 当然,并不需要你相当了解Unix 内核.

Template:Documentation/Tip

Template:Documentation/Note Template:Documentation/Tip

基本配置要求

硬件要求

  • 1 个或者多个CPU(速度当然会更快) (推荐x-系类CPU )* 1 GB 内存 (推荐2 GB )* 10 GB 可存储空间 (debug时需要20 GB )

软件要求

  • Windows XP/Vista/7

通过下面的表格, 当你使用其中的链接时,你可以轻松的返回. 这些项目解释如下. 表格里面的文件列表列出了中、需要下载的(附有下载链接)文件,这些文件必须放在相应的资源根目录下:


从那里获取这些文件 放置/使用配置
Cygwin: Cygwin 工具 (dll版本 1.5.10)或者更高版本 (默认)
C/C++ 编译器: 免费: C++ 2008 标准版 编译器 (基本安装, 没有可选要求) 专业版: Visual C++ 2008 Professional --with-cl-home=
Java: JDK 1.6 DEV300 版本 >= m37 适用于 OOo310 系列版本 (旧版本的java 在 hsqldb 模块下将会失败) --with-jdk-home=
Windows SDK for Windows Server 2008[1]
GDI+ Redistributable (Genuine Windows Validation required) main/external/gdiplus
dbghelp.dll[2]

也可以在Visual Studio C++ 2008Express安装文件中找到.

main/external/dbghelp
Apache Ant ( 1.6.5版本或者更高版本) --with-ant-home=
Mozilla binary distribution (WNTMSCIruntime.zip,WNTMSCIlib.zip,WNTMSCIinc.zip)

为了预建制模块moz(组件)目前使用的组件版本是1.1.4,不支持 Visual Studio C++ 2008编译器.

main/moz/zipped
msvcr71.dll 和 msvcp71.dll动态链接库,这两个dll在 Mozilla libraries 起作用(到PC上或者网络上搜寻这两个文件.这两个文件都是小写名,有时下载的这两个文件是大写名,这会导致建制时搜寻不到这两个文件)) main/external/msvcp71
msvcp80.dll 和 msvcr80.dll 这两个dll在 Mozilla libraries 中起作用;(我们可以再以下位置找到他们c:\WINDOWS/WinSxS/x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd/msvc) main/external/msvcp80
可选项: Nullsoft Scriptable Install System (NSIS)[3]
可选项: Microsoft DirectX SDK[4] --with-directx-home=


过期的Apache OpenOffice配置要求(已不适用):

从那里获得 安置
Apache OpenOffice不在需要的 仅仅适用于 OOo2.x版本 但根据bug报告 Issue 88652 3.x的配置中仍需要: unicows.dll from (Microsoft Layer for Unicode)[5] external/unicows
Apache OpenOffice不再需要的 instmsiw.exe and instmsia.exe external/msi
not needed anymore for Apache OpenOffice for 2008 compiler (until DEV300 m22): msvcp90.dll and msvcr90.dll (found in $(msvcdir)\Vc\redist\x86\Microsoft.VC90.CRT) external/msvcp90
Apache OpenOffice不再需要的 在 DEV300m23下开启2008编译器: Microsoft_VC90_CRT_x86.msm and policy_9_0_Microsoft_VC90_CRT_x86.msm for non debug builds and Microsoft_VC90_DebugCRT_x86.msm and policy_9_0_Microsoft_VC90_DebugCRT_x86.msm for debug builds[6]

. 这些联合的模块可以再vs08 Express版本和VS08 Professional版本下找到. 所有的 *.msm 文件 都在此位置 c:\Program Files\Common Files\Merge Module.

main/external/msm90

添加所有的文件到建制树

Template:Documentation/Tip

{{Template:Documentation/NoteOOo使用 Mozilla的库文件. 只有通过VC2003编译器才可能成功建立资源,所以你必须使用msvx71预编译库;在Windows系统中,Mozilla通讯录才需要Mozilla库支持; 不幸的是,有一个bug揭示:因为模块的依赖关系使得凡是依赖Mozilla库建立的模块必须依赖此模块,否则会失败; xmlsecurity (见下文).}}

Template:Documentation/Note

建制工具的准备和安装

建立cygwin

你可以到这里 http://www.cygwin.com/ 下载和安装最新版本的cygwin.

Documentation caution.png 请确保保持文件类型是"Unix/binary".
Documentation caution.png 请确保cygwin shell路径中没有包含空格和引号,否则配置将不会正常工作

额外需要的软件包

Cygwin由一系列基础的和可选的安装包组成. 在建立OOo时,你需要在安装器重选择一些可选的安装包,这些需要的安装包如下:

  • Category Archive:
    • unzip
    • zip
  • Category Devel :
    • autoconf
    • bison
    • flex
    • gcc-g++
    • gperf
    • make
    • openssl-devel (仅在用 perl modules 建立 CWS工具时有效 , 见下文)
    • mercurial (需要 cvs 2.x-3.0, 或者3.1 )
    • readline
  • Category Libs
    • openssl
  • Category Net
    • openssh
  • Category Perl
    • perl
  • Category Shells
    • mintty
  • Category Utils
    • patch
    • gnupg
  • Category Web
    • wget

Template:Documentation/Note

打破链接到可执行文件

在Cygwin工具包,一些可执行文件可能是符号链接,如awk.exe gunzip.exe,tar.exe(旧版本)。 这可能会导致生成时的中断,应用链接到它们的命令的副本更换符号链接 作为检查,请执行:

ls -l /bin/awk.exe

例如:awk,exe是一个连接,在版本1.5.24-2中awk.exe是一个链接到gawk.exe的链接,执行这个shell将显示“awk.exe->gawk.exe”,因此,必须用gawk.exe覆盖awk.exe,通过以下命令:

cd /bin
rm awk.exe
cp gawk.exe awk.exe


如果你忽略了一些东西或者你碰到新Cygwin版本里有一些符号链接从没有被提到过,这都没有多大关系. 你将会在稍后的配置步骤得到一个有用的有关链接错误告警消息,这个消息将告诉你不得不移除哪一个链接.你可以根据awk.exe/gawk.exe环节给出的建议来做.

在cygwin中安装额外perl 模块

如上所说,一些perl 模块必须用CPAN来安装.使用shell命令来完成必要的安装:

perl -MCPAN -e shell

如果这个命令第一次执行CPAN,它将会要求配置,请选择自动配置.

Documentation caution.png 请注意:CAPN不能过处理包含空格的用户名. 要解决这个事实, 当CPAN要求您指定的CPAN的构建和高速缓存目录 ,建议更改默认的目录到此 /cpan.

命令结束时,CPAN命令出现并随时准备接受命令进行安装;每一个模块使用命名 install $模块名. 一些必须被安装的模块是:

  • Archive::Zip
  • LWP::UserAgent

Apache OpenOffice不在适用:

  • XML::Parser (虽然它看来是已经安装了,这样做也不会有影响)
  • URI
  • Crypt::SSLeay
  • SOAP::Lite

CPAN将会侦测选择的模块是否依赖于其他的模块,同时也提供这些模块的下载;如上所说,请确认这些.

Template:Documentation/Note

Documentation caution.png 这有一个从CPAN错误例子:
C:\cygwin\bin\perl.exe: *** unable to remap C:\cygwin\bin\cygiconv-2.dll to same
address as parent(0x7C0000) != 0x7D0000

为了修正这问题, 退出Cygwin, 运行cmd.exe, 输入"c:\cygwin\bin\ash.exe" 启动ash.exe, 然后输入 /bin/rebaseall. CPAN将重新运行.

Documentation caution.png 一个发生在cygwin在make install时的错误例子 :
ERROR: Can't create '/usr/bin'; Do not have write permissions on '/usr/bin'

其实我可以写入到/usr/bin; 但是当我执行 ls -ld /usr/bin, cygwin提示不具有写入权限; 并且chmod u+w /usr/bin 提示 Permission denied(权限被拒绝). 这将导致因为权限拒绝而安装过程失败. 作为一个组合,我安装了vim 编辑了 / usr/lib/perl5/5.10/ExtUtils/Install.pm的368行,更换此:

return -w $dir;

替换为:

return 1;

这意味着允许安装进行.

全部建制

Documentation caution.png 请使用一个短的绝对路径来存储OpenOffice.org资源,例如 C:\ooo.否则,在后续的模块建制过程中将会因为某些建制动作命令行长度过长而出现奇怪的问题:
 1 [main] perl 1972 C:\cygwin\bin\perl.exe: *** fatal error - fork: can't reserve memory for stack 0x83C840 - 0x840000, 
Win32 error 487
 

配置

配置工具用于创建环境. 它将检测所有的软硬件信息和系统设备是否满足建制要求, 创建配置文件通过调用:winenv.set(tcsh)和winenv.set.sh(bash)文件来设置建制需要的环境变量.在运行配置之前,请确保所需的所有程序都在系统路径或通过相应的命令行启动配置.如果配置侦测到了问题将会停止并提示你有用的信息区修复配置.

从Mercurial库建制OOo: 你将发现配置信息脚本文件在根目录下;配置的结果文件也生成在根目录下.

从Apache的SVN存储库建设OOo:

$SRC_ROOT下调用autoconf. 它将生成配置步骤. 在每次在configure.in(无论是自己或其他任何人)更改配置步骤后和每次进行更改configure.in脚本,该脚本会提醒你重新运行autoconf.
autoconf

配置例子

你可以通过使用 ./configure --help来获得所有参数的简短的解释.

最精短配置(当然最基本的先决条件得满足)--路径根据不同设备而不同:

./configure 
 --disable-build-mozilla 
 --with-mozilla-build="/cygdrive/d/OOo/mozilla-build-1.3" \
 --with-cl-home="/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC" \
 --with-mspdb-path="/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/Common7/IDE" \
 --with-frame-home="/cygdrive/c/Program Files/Microsoft SDKs/Windows/v6.1" \
 --with-psdk-home="/cygdrive/c/Program Files/Microsoft SDKs/Windows/v6.1" \
 --with-midl-path="/cygdrive/c/Program Files/Microsoft SDKs/Windows/v6.1/Bin" \
 --with-asm-home="/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC/Bin" \
 --with-csc-path="/cygdrive/c/WINDOWS/Microsoft.NET/Framework/v3.5" \
 --with-jdk-home="/cygdrive/c/j2sdk1.5.0.06" \
 --with-directx-home="/cygdrive/d/OOo/DirectXSDK" \
 --with-ant-home=/ant \

这里有一些高阶设定能够帮助你拜托一些先决条件准备 这并不是每一个开发者都要求的(但是要注意,这操作会从最终的建制结果中删除某些部分):

 --disable-mozilla \
 --disable-activex \
 --disable-directx \
 --disable-atl \
 --without-junit \
 --disable-binfilter \
 --disable-odk \

以下是为了在比OOo330版本的版本或者比DEV300旧的版本中建制:

 --with-use-shell=bash

一些设置请慎重考虑:

 --enable-pch \
 --enable-werror \
 --enable-dbgutil \

如果你想要在你的磁盘中建立多个工作空间,将外部资源包文件设为共享将会是个不错的主意:

 --with-external-tar=d:/OOo/ext_sources \

配置设定提示

Documentation caution.png 确保Cygwin的shell的PATH变量中不包含任何空格和引号
Documentation caution.png 路径含有空格将会导致问题. 安装要求路径不能含有空格,另外,各种安装包使用默认的路径中包含空格,然后使用的混合短的路径的配置。 混合短路径可以使用Cygwin的cygpath的工具得到, eg:
$ cygpath -m -s "c:\Program Files\Microsoft Visual Studio 9.0\VC"
 c:/PROGRA~1/MICROS~1.0/VC

with-psdk-home设置需要区分大小写的路径名。 在任何情况下,我建议使用区分大小写的用法 - 如果你要使用Cygwin,区分大小写这是很好的习惯.

Documentation caution.png 注意使用/c/ 而不是 /cygdrive/c/.
Documentation caution.png 在配置参数中主意避免斜划线,在--with--psdk--home过程中斜划线将会导致问题.

Template:Documentation/Note Template:Documentation/Tip Template:Documentation/Tip {{Template:Documentation/Caution|If you run into problems compiling on an "Express Edition" (such as Cannot open include files: 'atlbase.h': No such files or directory), check your settings in winenv.set.sh for DISABLE_ATL, DISABLE_ACTIVEX: all have to be set TRUE. Visual Studio Express compilers do not contain everything needed to 建制OOo所需的全部ActiveX控件、自动OLE和原生Windows OLE支持,所以通过--disable-atl --disable-activex 禁用他们或者增加他们通过这里:via the WDK. Template:Documentation/Tip. Template:Documentation/Tip Template:Documentation/Tip Template:Documentation/Tip Template:Documentation/Tip

引导

在运行configure之后,你必须为创建OpenOffice.org而创建一个dmake make实用程序。 通过这从SRC_ROOT(根目录)目录下调用

./bootstrap

Template:Documentation/Note

设定环境

当配置脚本成功运行后,winenv.set.sn文件将会生成;请执行:[7]. 请执行:

source winenv.Set.sh

来设定建制的环境.

开始建制

请在根目录下输入以下来建制$SRC_ROOT[8]:

dmake

建制过程至少需要一个小时(3GHz,4核,8G内存).

OOo在建制其模块过程中有很多特别的东西,每个模块在它第一次建制过程中都有一个“输出”文件夹(输出生成的一些子文件夹)生成.通过MSVC++2003建制的文件夹名字是“wntmsci10.pro”,在MSVC++2005和MSVC++2008建制下该文件夹名字是“wntmsci12.pro”.成功建制一个模块之后一些生成的文件通过执行一个名为“deliver”的工具(自动在建制每一个模块中执行)复制到一个命名为“solver”模块输出文件夹中.其他的模块将使用这些“deloverd”文件(头文件,库...)来解决他们之间的依赖;solver模块的内容页将被用来包装最后的安装步骤.

Template:Documentation/Tip


部分建制

有两种部分建制的方法:

  • 兼容的
  • 不兼容的

如果你清楚你正在干什么那么可以选择兼容模式; Template:Documentation/Note

rebuilding from a module (incompatible build)

If you decide to change a module in an incompatible way, you will need to rebuild all modules depending on it (directly or indirectly):

cd $SRC_ROOT/instsetoo_native
build --from $INCOMPATIPLEMODULE --prepare
build --from $INCOMPATIBLEMODULE

rebuilding a module (compatible build)

To rebuild a module you can delete all output directories with, rebuild and redeliver into the solver with:

cd $MODULE
build --from $MODULE --prepare
build && deliver

A simple build in $SRC_ROOT/instsetoo_native will recreate the installation sets, provided all other modules have already been build.[9]

Building a Module with Debug Information

To rebuild a module with debug information and additional assertions and checks, run:

cd $MODULE
build --from $MODULE --prepare # removes old output trees and solver
build debug=true --from $MODULE

Drop the newly created binaries into an existing installation. Building an installation set with them will not help, as binaries are stripped on packing by default.

Template:Documentation/Tip

Finding the Installation Sets

After a successful build you will find the OOo installation set in

instsetoo_native/wntmscixx.pro/OpenOffice/msi/Install/en-US

“instsetoo_native” is the module that packs the installation set.

Template:Documentation/Tip

Tips And Tricks

ccache

For Windows: download from here, do the following:

export CCACHE_DIR="some/place/with/space"
ccache -M 2G -F 10000
export CCACHE_CPP2=TRUE
export CXX="guw.pl ccache cl"
# export USE_PCH=  if you experience trouble with precompiled headers

dependencies

nodep

If you set the environment variable nodep to TRUE, then dependendy information files are not created - the build finishes faster.

Documentation caution.png But only enable that on a clean build. Once you have built OOo and then made modifications, unset the variable again to be on the safe side.

NO_HIDS

Similar to the nodep variable, this one prevents the generation of HIDs (Help IDs) that are mainly used for automated testing - if you only want to build OOo, you don't need those.

parallel builds

If you have a multiprocessor machine or similar, you can run a parallel build. There are two levels of parallelism - one operating on makefile (directory) level, the other one on the global level. The two levels of parallelism result from the two-step build procedure in the OOo build environment. The build script runs through all the directories it reads from the build.lst files in all modules and calls dmake for every directory.

parallelism on the global level

For parallelism on the global level, you have to run build from $SRC_ROOT>/instsetoo_native with the -P<number> switch, for example:

build -P2

This takes build how many dmake processes it is allowd to start in parallel.

parallelism on the directory level

export MAXPROCESS=<numer or processes> 

This tells dmake how many targets it is allowed to build in parallel. When you don't use build.pl but build a single directory (single makefile), you can achieve the same with

dmake -P2

combining both levels

If you want to have parallelism on both levels, you can call

build -P2 -- -P2

"--" is a special build.pl parameter that passes every further parameters to the dmake processes it starts.

Recommendation

Experience tells that using the doubled number of cores in your machine is a good choice, using more threads does not make a big difference, except if the combined option is chosen. So even on single core machines using two threads will speed up the build considerably.

create prebuilt mozilla

For the mozilla-components you have the choice to either build from mozilla sources, to use precompiled packages or to use system-mozilla (the one installed on your buildsystem, not everything might work, depending on the version you got installed). You can easily create your own version of the prepacked binaries if you wish to do so (either because you cannot use the official ones because of mismatch of compiler version used to build them/other technical reasons or because you want to use stuff you didn't build yourself). To do so:

  • build the moz module from the mozilla sources
  • use --enable-build-mozilla when running configure and put the mozilla-source tarball to moz/download
  • in moz run dmake zip to create the zip files
  • you'll find the zips in {platform}.pro/zipped

Copy them to a location of your liking. Now instead of using --enable-build-mozilla, use --disable-build-mozilla and copy the zips you created or downloaded to moz/zipped and these will be used when compiling. This will greatly reduce build-time (you save the time that would otherwise be spent on compiling mozilla).

See Also

Template:Documentation/Note


  1. Template:Documentation/Note
  2. Template:Documentation/Note
  3. Template:Documentation/Note
    Documentation caution.png It used to be that newer version of NSIS broke the build (see Issue 85657 ), but it seems that it now works for NSIS up to 2.3.7.
  4. Template:Documentation/Note
    Documentation caution.png Current (as of 2008/01) versions of the DirectX9 SDK and Windows Platform SDK do not fit to each other. To be able to build with DirextX enabled, you need to patch one file in the Platform SDK. See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID2743771 for details.
    Documentation caution.png Do not use a DirectX10 SDK!
  5. Template:Documentation/Note
  6. Template:Documentation/Note
  7. Template:Documentation/Note
  8. Template:Documentation/Note
  9. Documentation caution.png build --all would rebuild changed/missing files. However, it does not check for incompatible modules. If unsure, use build --from --prepare.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools