Database/Drivers/MySQL Native/OOoBuildEnvironment

From Apache OpenOffice Wiki
< Database‎ | Drivers‎ | MySQL Native
Revision as of 08:01, 22 June 2010 by Sb (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to set up an Build environment for C/OOo development

SuSE Linux

SuSE 11

SuSE 11 does not use Sun Java by default. The default installation will come with GNU Java and javac = GCJ. Don't use the GNU stuff, use Sun's Java SDK 1.5. Deinstall GNU Java, search for java and gcj in Yast. OpenOffice 3.0 M28 might fail to detect GNU Java and might not come up with any proper error message during configure.


If your connection is not OC-192 ;), then you might want to log into a server with a fast connection and do the following there. The just pack the sources and download them locally using scp.


This list is based on what is needed to be additionally installed on a virgin Ubuntu 8.10 Interpid/Debian 4r6 Etch system. If might be different for you, meaning you might need to install more packages. However, be sure you have these to skip some iterations of [configure [, install ]]+

  • libarchive-zip-perl (Perl Archive/Zip)
  • libcupsys2-dev
  • libpam0g-dev
  • sdk-java 1.5
  • gperf
  • libfreetype6-dev
  • libxaw7-dev
  • libfontconfig1-dev
  • libxrandr-dev
  • libgconf2-dev
  • libgnomevfs2-dev
  • libgdk-pixbuf-dev
  • ant
  • bison
  • flex
  • zip
  • unzip

Get sources

  • Without a key
svn checkout svn://
cd DEV300_m39
svn switch svn://
  • Get sources - with a key
svn checkout svn+ssh://
cd DEV300_m39
svn switch svn+ssh://


cp /path/to/download/of/unowinreg.dll external/unowinreg/
cp /path/to/download/of/ moz/zipped/
cp /path/to/download/of/ moz/zipped/
cp /path/to/download/of/ moz/zipped/

OpenOffice will search for <OS><COM><CPU>{inc,lib,runtime}.zip in moz/zipped/ . You might have to rename the download files. Watch out for error messages returned by configure (see below).

  • Configure (distribution build - "pro" build)
cd config_office
./configure --disable-build-mozilla --disable-mediawiki
  • Configure (debug build, with asserts - "non-pro")
cd config_office
./configure --disable-build-mozilla --disable-mediawiki --enable-dbgutil

I was able to configure on openSuSE11.0 with the following command, after installing all needed libraries :

./configure --disable-build-mozilla --disable-mediawiki --with-system-freetype \
--with-system-stdlibs --with-system-cairo --with-system-zlib  --with-system-openssl --with-system-jpeg \
--with-system-expat --with-system-freetype --with-system-libwpd --with-system-libxml --with-system-python \
--with-system-icu --with-system-db --with-system-lucene  --with-system-hsqldb --with-system-beanshell \
--with-system-libxslt --with-system-odbc-headers --with-system-sane-header --with-system-curl \
--with-system-boost  --with-system-vigra --with-system-neon

I tried --with-system-libs but got into problems finding some packages. If you get libegg problems (I do) add --disable-systray

  • M39: configure seems broken.

Fix, if need be. In my case its necessary to modify SYSTEM_HSQLDB to:

 ToFile( "SYSTEM_HSQLDB",     "NO",    "e" ); 

Also, mysqlcppconn did not compile out-of-the box. It did not find mysql.h and shows the to be expected follow-up errors like mysql_<funcname> not found. I fixed it by modifying to "emulate" --with-system-mysql.


  • Follow the messages, probably you have to do the following, if you have used bash as shell for the build in the configure line. For tcsch use LinuxX86Env.Set:
cd ..
  • If you have dual or quad-core, or SMP, run the following and adjust for your configuration
  • ccache is very recommended, go install it. Then configure it to have enough space. By default it stores data in your home directory. This is configurable like (I have CC and CXX changed in .bashrc but some people prefer to do a symlink):
export CCACHE_DIR="/path/to/ccache/dir/for/"
ccache -M 2G -F 100000
export CC="ccache gcc"
export CXX="ccache g++"
  • dmake should have been boostrapped. Now just run the following and go get a 6h sleep :)

SSH Keys

On Unix or Windows/cygwin a SSH identity (private/public key pair) is generated with:

ssh-keygen -t dsa

You'll be asked for pass phrase which protects your private key. Per default the public key is named $HOME/.ssh/ Note that SSH keys created between September 2006 and May 2008 on Debian or Debian derived systems like Ubuntu may be insecure. Please use recent SSH tools. If you want a dedicated identity for just OOo SVN usage, generate a specially named key pair:

ssh-keygen -t dsa -f ~/.ssh/id_dsa_ooo_svn 

and instruct Subversion to use this identity (key pair) with the following configuration entry in $HOME/.subversion/config:

ssh = ssh -i /home/andrey/.ssh/id_dsa_ooo_svn

RPM Installation

Something like this...

rpm -Uhv ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/  ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./instsetoo_native/ ./sysui/ ./sysui/

DEB Installation

Something like this...

cd instsetoo_native/ sudo dpkg -i *.deb cd desktop_integration sudo dpkg -i *.deb

Then the programs are in /opt/openoffice3/program/

Compiling the driver

Ok, you got to compile, and it has finished compiling after 3-6 hours.

Patching the CWS (you need this if you don't use m37 or up)

The latest driver code is still not in the CWS. You need to fetch it from bazaar. We will streamline compiling and commit the source into the CWS as soon as possible. Make sure that you have the OOo build environment set up when compiling the driver (source etc.)

Add the MySQL driver to the source tree:

DEV300_m35> cd connectivity/source/drivers/
DEV300_m35/connectivity/source/drivers> bzr clone bzr+ssh://<user>

Add the driver to the OOo build process by patching connectivity/prj/build.lst:

DEV300_m35> nano connectivity/prj/build.lst

Add a line to the build list for compiling the mysql driver, for example:

cn  connectivity\source\drivers\trunk               nmake   -   all cn_mysqlc cn_dbtools cn_inc NULL

Compiling the driver (manually)

The configure flags --enable-mysql-driver, --with-system-mysql and --with-system-mysqlcppconn are work in progress. They may or may not work when you read this. The first goal is to get the driver compile at all. Later on, we can make it user-friendly and Linux distribution-friendly. Manual fine-tuning of makefiles is to be expected - for now.

"Standalone build"

Builds the driver with as little external requirements as possible. In this configuration you will create a static build. The driver will be build against the MySQL Connector/C++ sources contained in the CWS.

However, you must have the MySQL Server installed on your system. At the time of writing, you should use --with-system-mysql on Linux. Use grep to ensure that its set and, if not, set SYSTEM_MYSQL="YES" in your environment:

DEV300_m37> grep SYSTEM_MYSQL

On Windows you should use SYSTEM_MYSQL="NO" and consequently omit --with-system-mysql when configuring You will need to edit mysqlc/ and patch it to point to your MySQL installation directory and the location of the MySQL Client Server Library:

DEV300_m37> grep -n "MYSQL_.*DIR" mysqlc/
72: MYSQL_LIBDIR=D:$/mysql-5.1.24-rc-win32$/lib$/debug
73: MYSQL_INCDIR=D:$/mysql-5.1.24-rc-win32$/include
78: MYSQL_LIBDIR=/export/home/oj93728/mysql/lib
79: MYSQL_INCDIR=/export/home/oj93728/mysql/include

The basic steps are:

  • Install the MySQL Server on your build host
  • Build and deliver mysqlcppconn/ (the MySQL Connector/C++ used by the driver)
  • Build and deliver connectivity/
  • Build and deliver mysqlc/ (the MySQL native driver for

On the command line it looks like:

DEV300_m37> cd mysqlcppconn/
DEV300_m37/mysqlcppconn> dmake killobj && build --all && deliver
DEV300_m37> cd ../connectivity
DEV300_m37/connectivity>  rm -rf unxlng* && build --all && deliver
DEV300_m37> cd ../mysqlc
DEV300_m37/mysqlc> dmake killobj && build --all && deliver

Hint: usually you can omit "dmake killobj" and "rm -rf unxlng*" to clear compile caches.

Check the build message for the location of the extension, for example:

DEV300_m37> dmake killobj && build --all && deliver
cp -f /tmp/mkdF4yFR.mysql-native_.oxt  ./
rm -f /tmp/mkdF4yFR.mysql-native_.oxt
rmdir /tmp/11964
deliver -- version: 1.130
Module 'mysqlc' delivered successfully. 0 files copied, 1 files unchanged

"System build"

This describes a set up where you compile the extension against the MySQL Connector/C++ installed on the system. The usage of --with-system-mysqlcppconn may or may not work. We are focussing on the "standalone" build for the moment.

TODO: There seems to be a dispute in the developer group if --with-system* refers to build or to build and compile time. The question is if --with-system* is set, should an extension contain all libraries it depends on or not. For example, if --with-system-mysqlcppconn is set, should the MySQL Connector/C++ libraries be part of the extension or not. However, this is a question that goes beyond the scope of the MySQL driver. Its a general question to be discussed on a general level.

Driver/extension installation

You can either install the extension in the GUI or use "unopkg". If you want to use "unopkg" make sure that you run it in a shell that does NOT have the build environment set up (source etc. must NOT have been run before).

> /opt/openoffice.org3/program/unopkg list
all deployed user packages:
Identifier: org.openoffice.legacy.mysql-native.oxt
 Version: 0.0.1
 is registered: yes
 Media-Type: application/
 bundled Packages: {
     is registered: yes
     Media-Type: application/;type=native;platform=Linux_x86
> /opt/openoffice.org3/program/unopkg remove org.openoffice.legacy.mysql-native.oxt
> /opt/openoffice.org3/program/unopkg add ~/DEV300_m35/connectivity/

Debug hints

If you follow the above instructions you create a debug build.

You can enable the libmysql and Connector/C++ internal traces. To enable the Connector/C++ trace (should be on by default ATM), patch driver/mysql_debug.h:

#ifndef _MYSQL_DEBUG_H_
#define _MYSQL_DEBUG_H_
#if 1
#define CPP_ENTER(msg)                  MySQL_DebugLogger * __l = this->logger? this->logger->get():NULL;(void)__l;\
                                                               MySQL_DebugEnterEvent __this_func(__LINE__, __FILE__, msg, logger)
#define CPP_ENTER_WL(l, msg)    MySQL_DebugLogger * __l = (l)? (l)->get():NULL;(void)__l;\
                                                               MySQL_DebugEnterEvent __this_func(__LINE__, __FILE__, msg, (l))
#define CPP_INFO(msg)           {if (__l) __l->log("INF", msg); }
#define CPP_INFO_FMT(...)       {if (__l) __l->log_va("INF", __VA_ARGS__); }
#define CPP_ERR(msg)            {if (__l) __l->log("ERR", msg); }
#define CPP_ERR_FMT(...)        {if (__l) __l->log_va("ERR", __VA_ARGS__); }

Also flip the default setting for generating debug output in driver/mysql_debug.cpp. Modify the constructor and set tracing to true:

/* {{{ MySQL_DebugLogger::MySQL_DebugLogger() -I- */
  : tracing(true)
/* }}} */

When building mysqlc, don't forget to enable C/OOo debug output using:

 cd mysqlc
 build --all debug="something"

OpenSolaris notes (OUTDATED)

NOTE: I'm still fighting with OpenSolaris issues NOTE: The OOo team works only on Solaris 8(!).

  • Install OpenSolaris from 2008.05 CD image (Sun Microsystems Inc. SunOS 5.11 snv_86 January 2008)
  • Update OpenSolaris to current version

The update will download approx. 1.5 - 2 GB. Accordingly it will take some time.

pfexec pkg refresh
pfexec pkg install SUNWipkg
pfexec pkg image-update
pfexec mount -F zfs rpool/ROOT/opensolaris-1 /mnt
pfexec /mnt/boot/solaris/bin/update_grub -R /mnt
pfexec reboot

At the time of writing you will end up with SunOS opensolaris 5.11 snv_95 .

  • Install additional packages required for compiling OOo 3.0

Start with SunStudio (ss-dev) and assorted development libraries/tools. That's another ~700MB to download.

pfexec pkg install SUNWcvs ss-dev SUNWxorg-headers SUNWgnu-gperf SUNWcurl
pfexec pkg install SUNWgnome-common-devel SUNWxwinc SUNWant SUNWlxml SUNWicu

There is a bug in OpenSolaris and SUNWxorg-headers will not install all required X headers/libraries! You need to install old versions of the FSWxorg-headers package. You must use old versions because newer versions are empty - their binaries conflict with SUNWxorg-headers and OpenSolaris decided to silently distribute empty packages. Use pfexec pkg contents FSWxorg-headers to check wheter this has been fixed... if not:

pfexec pkg install FSWxorg-data@0.5.11-0.79  FSWxorg-headers@0.5.11-0.79
  • Fix/Hack libXaw installation

As explained the FSWxorg* and SUNWxorg* packages might conflict. You need some header from FSWxorg* including libXaw. However, you need to compile libXaw manually although some of its headers are part of FSWxorg-headers.

export PATH=$PATH:/opt/SunStudioExpress/bin/:/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin:/usr/local/bin/
bunzip2 libXaw-1.0.4.tar.bz2
tar xvf libXaw-1.0.4.tar
cd libXaw-1.0.4
CC=cc ./configure --prefix=/usr/X11
make install
  • Install missing Perl packages

OOo needs some Perl packages. You will need to install at least Archive::Zip. Some Archive::Zip dependencies might require a C compiler. If you run into issues make sure that you give Perl whatever C compiler it wants. If possible go for the Sun Compiler (CC=/opt/SunStudioExpress/bin/cc CXX=/opt/SunStudioExpress/bin/CC).

export PATH=$PATH:/opt/SunStudioExpress/bin/:/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin:/usr/local/bin/
perl -MCPAN -e shell
shell> install Archive::Zip
  • Install sources as described for Linux
  • Patch configure

The OOo team does use one Solaris 8 reference system to cover all *Solaris* versions. Naturally this means that configure will not work out-of-the-box on OpenSolaris. You will need to fix several issues manually. Check out for:

    • SunStudio C Compiler wrong version - found 5.10 needs 5.9

That's nothing but a stinky configure. Add a test for 5.10 to configure and make configure accept 5.10.

    • Wrong ANT version 1.6.5 needs at least 1.6.0

You need to set the JAVA_HOME through --with-jdk-home=/usr/jdk/latest

    • Cannot find ANT libraries

Check the location of ant.jar using

 pfexec pkg search -r ant.jar 

As you will see, the path it has changed over time. OOo does not search any of the OpenSolaris places by default. Find out the current location using

 pkg contents -t file SUNWant  | grep ant.jar

At the time of writing its usr/share/lib/ant/ant.jar . Either patch configure or set ANT_HOME - export ANT_HOME=/usr/share/lib/ant

  • Run configure

You are getting closer to running configure... Make sure you say "bash". For whatever reason it sets the appropriate path to the GNU patch utility.

export PATH=$PATH:/opt/SunStudioExpress/bin/:/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin:/usr/local/bin/
CC=cc CXX=CC ./configure --disable-build-mozilla --disable-mediawiki --with-jdk-home=/usr/jdk/latest/ --with-system-curl

See above on known configure issues.

  • Source && Bootstrap
nixnutz@opensolaris:~/$ cd ..
nixnutz@opensolaris:~/$ source
nixnutz@opensolaris:~/$ ./bootstrap
  • Start building OOo using dmake
nixnutz@opensolaris:~/$ dmake

Most likely this will fail! Why? OOo will invoke the make utility with GNU make specific flags. Even more: OOo might try to build icu and the bundled icu will not build with Sun make at all. You might need to use GNU make. I have no idea how to tell OOo that it shall use /usr/gnu/bin/make instead of /usr/ccs/bin/make. I modified the soft link /usr/ccs/bin/make - blame me...

Personal tools