Difference between revisions of "Development Environment with solver"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Added descriptions about patches for gcc-3.4.1 and revised some lines here and there.)
Line 541: Line 541:
  
 
</div></blockquote>
 
</div></blockquote>
 
[[Category:Development]]
 
 
[[Category:Build_System]]
 
[[Category:Build_System]]

Revision as of 13:14, 28 March 2010

Introduction

This document describes how to set up an OpenOffice.org development environment with solver in a few hours.

Target readers

Software engineers who want or need to fix a bug or to enhance OpenOffice.org.

Two ways to set up an environment

There are at least two ways to set up a development environment: entire build and use of solver.

Method Steps Merits Drawbacks
Entire build

1. Download source tar-balls of OpenOffice.org.
2. Extract them.
3. Build OpenOffice.org entirely from scratch.

No need to take care of distribution.

Need to wait until build process is finished. It might be for more than one day.

Impossible to provide your customers with patch files. You will have to deliver an installer of OpenOffice.org and your customers will need to uninstall an official OpenOffice.org built by the community and then install your own OpenOffice.org. You might be responsible for the whole OpenOffice.org.

Use of solver

1. Download both source tar-balls and solver of OpenOffice.org.
2. Extract them.

No need to wait.

Possible to provide your customers with patch files. All your customers need is to replace some files already installed in their PC with the patch files. You would not be responsible for the whole OpenOffice.org but only part of OpenOffice.org.

Need to carefully choose a distribution that meets an environment used for the community builds.

This document will explain the latter one, use of solver.

solver

Solver is a name of folder that holds all the necessary files created during a process of building OpenOffice.org.

The OpenOffice.org community normally delivers an installer of OpenOffice.org along with the corresponding solver.

Further information on solver can be found at http://www.openoffice.org/dev_docs/source/solver.html

Conventions

  • In this document it is assumed that you are using bash.
  • To make it easy to copy some example command lines in this document and paste them into your terminal emulator, a shell prompt is intensionally omitted. Please differentiate which line is a command that you will type and which line is an output that is produced by the command.
  • When invoking a UNIX command, you should be an appropriate user, a super user or normal user.

For example, the following example cited in this document

./configure
make 
make install

implies

(normal user)$ script
(normal user)$ ./configure
(normal user)$ make
(normal user)$ exit
(normal user)$ /bin/su
(super  user)# script -a
(super  user)# make install
(super  user)# exit
(super  user)# exit


Development Environment on Linux

Prerequisites

Firstly, it would be meaningful to know the System Requirements for OpenOffice.org 2 released by the community. It says that

Linux kernel version 2.2.13 or higher, glibc2 version 2.2.0 or higher

The Linux kernel-2.2.13 became available late in 1999. Looking for similar distributions, you would find some:

Nowadays it is relatively difficult to get such a somewhat antique distribution. So we will need to find an alternative.

Choosing a Linux distribution

Secondarily, choose a Linux distribution. There are many distributions currently available. Since the 'solver' seems to be created on the environment firstly prepared in the year of around 2000, some of the distributions can work with it, but others can not.

Fedora Core Distributions

Fedora Core and Fedora distributions are freely available and widely used in the world.

Versions of the packages bundled in the Fedora Core and Fedora distributions

Package FC1 FC2 FC3 FC4 FC5 FC6 Fedora 7 Fedora 8
kernel 2.6.5 2.6.9 2.6.11 2.6.15 2.6.18 2.6.21 2.6.23
glibc 2.3.3 2.3.3 2.3.5 2.4 2.5 2.6 2.7
gcc 3.3.3 3.4.2 4.0.0 4.1.0 4.1.1 4.1.2 4.1.2
binutils 2.15.90 2.15.92 2.15.94 2.16.91 2.17.50 2.17.50 2.17.50
ant 1.5.2 n/a 1.6.2 1.6.5 1.6.5 n/a 1.7.0
scim n/a n/a n/a 1.4.4 1.4.4 1.4.5 1.4.7

n/a: Not Available

Dependencies

Choice

Fedora Core 4 plus gcc-3.4.1 seems to be the better choice among the Fedora distributions.

Setting up development environment

Setting up a Fedora Core 4 box

  1. Visit http://fedoraproject.org/
  2. Follow links to find a list of mirror servers.
  3. Download core/4/i386/iso/FC4-i386-DVD.iso
  4. Install it.
  5. Additionally install necessary packages, if needed.

To use yum, you will need to create a directory 'repodata' since FC4-i386-DVD.iso does not have it while an iso image of Fedora 8 does.

mount -o /dev/cdrom /mnt
mkdir /var/tmp/RPMS
cd /var/tmp/RPMS
ln -s /mnt/Fedora/RPMS/* .
createrepo .

To use the repodata, specify a path of the directory in which repodata is.

cd /etc/yum.repos.d
mkdir disabled
mv *.repo disabled
cat > dvd.repo 
[dvd]
name=Fedora 4 Install DVD
baseurl=file:///var/tmp/RPMS
gpgcheck=0
^D
yum list
yum install name_of_package
mv disabled/* . 
mv dvd.repo disabled
umount /mnt

Installing gcc-3.4.1

  1. Visit http://gcc.gnu.org/
  2. Follow links to find a list of mirror servers.
  3. Download releases/gcc-3.4.1/gcc-3.4.1.tar.gz
  4. Apply two patches following an article [porting-dev] OOo Linux builds: Hamburg RE switches over to gcc-3.4.1 by Jens-Heiner Rechtien.
    1. enum patch - http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00968.html by Jakub Jelinek
    2. visibility patch - http://www.nedprod.com/programs/gccvisibility.html by Niall Douglas
  5. Install it following instructions at gcc-3.4.1/INSTALL/index.html
bunzip2 -dc gcc-3.4.1.tar.bz2 | tar zxf -
cd gcc-3.4.1
patch -p0 < ../Fix_C++_enums_handling_in_build_range_check.patch
patch -p1 < ../GCC3.4.0VisibilityPatch2.diff
mkdir -p build/object
cd build/object
../../configure '--enable-languages=c,c++'
make bootstrap
make install

Here is an example file Fix_C++_enums_handling_in_build_range_check.patch
This example is cited from http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00968.html
and then a portion "--- gcc/fold-const.c.jj" in the first line is intentionally replaced with "--- gcc.original/fold-const"

--- gcc.original/fold-const	2004-07-09 13:50:54.000000000 +0200
+++ gcc/fold-const.c	2004-07-09 18:10:52.945905468 +0200
@@ -3844,7 +3844,13 @@ build_range_check (tree type, tree exp, 
       HOST_WIDE_INT hi;
       int prec;
 
-      prec = TYPE_PRECISION (etype);
+      /* For enums the comparison will be done in the underlying type,
+	 so using enum's precision is wrong here.
+	 Consider e.g. enum { A, B, C, D, E }, low == B and high == D.  */
+      if (TREE_CODE (etype) == ENUMERAL_TYPE)
+	prec = GET_MODE_BITSIZE (TYPE_MODE (etype));
+      else
+	prec = TYPE_PRECISION (etype);
       if (prec <= HOST_BITS_PER_WIDE_INT)
 	{
 	  hi = 0;

Installing JDK

  1. Visit http://java.sun.com/
  2. Follow a link 'Java SE' to find a JDK 6.
  3. Download and install it.
/bin/sh jdk-6u3-linux-i586-rpm.bin

Tweaking pre-installed ant

Since the pre-installed ant bundled in Fedora Core 4 does not work with JDK released by Sun, clear an environment variable JAVA_HOME which will be assigned by LinuxX86Env.Set.sh .

  1. Backup /etc/ant.conf
  2. Edit /etc/ant.conf to append a line 'JAVA_HOME=' at the end of file.
cp -p /etc/ant.conf{,-original}
vi /etc/ant.conf
diff /etc/ant.conf{-original,}
22a23
> JAVA_HOME=

Downloading files

Getting files of OpenOffice.org

You will need an installer, source tar-balls, and solver of OpenOffice.org.

  1. Visit http://download.openoffice.org/ .
    1. For OOo 2.3.0, http://download.openoffice.org/2.3.0/source.html
    2. Mirrors: http://distribution.openoffice.org/mirrors/#extmirrors
  2. For 2.3.0, download the following files:
    1. stable/2.3.0/OOo_2.3.0_LinuxIntel_install_wJRE_en-US.tar.gz or localized/your_preferable_language/2.3.0/OOo_2.3.0_LinuxIntel_install_wJRE_xxxxx.tar.gz
    2. stable/2.3.0/OOo_2.3.0_src_binfilter.tar.bz2
    3. stable/2.3.0/OOo_2.3.0_src_core.tar.bz2
    4. stable/2.3.0/OOo_2.3.0_src_l10n.tar.bz2
    5. stable/2.3.0/OOo_2.3.0_src_sdk.tar.bz2
    6. stable/2.3.0/OOo_2.3.0_src_system.tar.bz2
    7. extended/2.3.0rc3/OOo_2.3.0_LinuxIntel_solver.tar.gz
  3. Install OOo_2.3.0_LinuxIntel_install_wJRE.xxx following instructions http://download.openoffice.org/common/instructions.html
  4. Expand the source tar-balls.
  5. Expand the solver tar-balls.
fox x in /where_downloaded/stable/2.3.0/OOo_2.3.0_src_*.tar.bz2; do bunzip2 -dc $x | tar -xf -; done
tar -zxf /where_downloaded/extended/2.3.0rc3/OOo_2.3.0_LinuxIntel_solver.tar.gz
cd OOG680_m5
ln -s ../solver .

Getting extra files

You will need some extra files.

unowinreg.dll

cp -p solver/680/unxlngi6.pro/bin/unowinreg.dll external/unowinreg

moz/download

cd moz/download
wget -nd -r http://releases.mozilla.org/pub/mozilla.org/mozilla/releases/mozilla1.7.5/source/mozilla-source-1.7.5.tar.bz2
cd ../..

Configuration

Running configure

  1. Run the shell script configure .
cd config_office
sh -xv LinuxConfig.sh

Here is a sample shell script LinuxConfig.sh for the configure .

#!/bin/bash --norc
export LANG=C
export PATH=/bin:/usr/bin:/usr/X11R6/bin
export CC=/usr/local/bin/gcc
export CXX=/usr/local/bin/g++
./configure \
--with-jdk-home=/usr/java/default \
--with-use-shell=bash

Making dmake

  1. Make dmake using a shell script bootstrap created by the configure .
cd ..
./bootstrap

Building a module

Preparation

You will need to set up certain environment variables.

  1. Run the shell script LinuxX86Env.Set.sh
. LinuxX86Env.Set.sh

Building a module

  1. Run an alias command build to build a module
cd sw
build

Options of build

To add an option -g to gcc, give an option debug=1 to the alias command build.

build debug=1

To add a CFLAGS,

build debug=1 envcflagscxx=-DHDU_DEBUG

To add more than one options,

build debug=1 'envcflagscxx="-DHDU_DEBUG -DTORA_DEBUG"'

Known error messages

If you encounter the following error messages that prevent building process, try some solutions described here.

version `CXXABI_1.3.1' not found

Checking DLL ../unxlngi6.pro/lib/check_libsw680li.so ...: ERROR: /xxx/2.3.0/OOG680_m5/solver/680/unxlngi6.pro/lib/libstdc++.so.6: version `CXXABI_1.3.1' not found (required by ../unxlngi6.pro/lib/check_libsw680li.so)
  • Solution: Use gcc-3.4.x instead of gcc-4.x.x

referenced in section `.rodata' of ... defined in discarded section `.gnu.linkonce.t. ...

`.L125' referenced in section `.rodata' of ../unxlngi6.pro/slo/grfatr.o: defined in discarded section `.gnu.linkonce.t._ZN3com3sun4star3unorSERKNS2_3AnyERd' of ../unxlngi6.pro/slo/grfatr.o

undefined reference to `__ctype_b'

/xxx/2.3.0/OOG680_m5/solver/680/unxlngi6.pro/lib/libaudio.a(ConnSvr.o)(.text+0x1be): In function `MakeTCPConnection':
ConnSvr.c: undefined reference to `__ctype_b'
/xxx/2.3.0/OOG680_m5/solver/680/unxlngi6.pro/lib/libaudio.a(ConnSvr.o)(.text+0x5a8): In function `_AuConnectServer':
ConnSvr.c: undefined reference to `__ctype_b'
/xxx/2.3.0/OOG680_m5/solver/680/unxlngi6.pro/lib/libaudio.a(ConnSvr.o)(.text+0x5b1):ConnSvr.c: undefined reference to `__ctype_tolower'
/xxx/2.3.0/OOG680_m5/solver/680/unxlngi6.pro/lib/libaudio.a(ConnSvr.o)(.text+0x755):ConnSvr.c: undefined reference to `__ctype_b'
collect2: ld returned 1 exit status
  • Solution: Run "build" with LINKFLAGSDEFS= that is normally specified as "LINKFLAGSDEFS*=-Wl,-z,defs" in solenv/inc/unxlngi6.mk
  • References: an option "-z defs" of ld
LINKFLAGSDEFS= build

Debugging your source code

Now that you have your own shared files (.so) in your development environment.

To debug your code, you will need to replace shared files in the installation set of OpenOffice.org with your shared files that have been just made from your source code.

Replacing shared files in the installation set

  1. Backup original shared files.
  2. Create symbolic link files addressing to your own shared files.
cd /opt/openoffice.org2.3/program
mkdir original-sw
mv libsw*.so original-sw
ln -s /your_development_environment/sw/unxlngi6.pro/lib/libsw*.so .

Debugging with gdb or ddd

  1. Start your OpenOffice.org with a sample document file to test your source code.
  2. Use a function in OpenOffice.org in order to load relevant shared library files that you want to debug. E.g. if you want to debug one dialog window in Writer, you would need to start Writer to load shared library files of Writer and then choose a certain entry in the menu or click on a certain button on the tool bar to load UI related shared file of Writer. Otherwise, your dbg would not load any symbol in the target shared library files at its startup. For more details, see help about the the following commands of gdb: info sharedlibrary, add-symbol-file.
  3. Find a process id of soffice.bin with pgrep .
  4. Start gdb or ddd givinning the process id to attach to the process of OpenOffice.org
/opt/openoffice.org2.3/program/soffice sample.odt &
pgrep soffice.bin
nnnnn
gdb /opt/openoffice.org2.3/program/soffice.bin nnnnn

or, more simply,

/opt/openoffice.org2.3/program/soffice sample.odt &
gdb /opt/openoffice.org2.3/program/soffice.bin `pgrep soffice.bin`

Tips of gdb and ddd

Since OpenOffice.org is written in two languages, c and c++, the debugger sometime mistakenly chose a type of language. If you encounter an error message like this,

break xxx::yyy
Can't find member of namespace, class, struct, or union named "xxx::yyy"

try to explicitly specify a type of language.

set language c++
Personal tools