Build QuantLib Calc Addin on Windows and/or Linux
NB: For the current release of QuantLibAddin 1.22.0, the LibreOffice build has not been updated. The documentation on this page is out of date and relates to an older build of the LibreOffice addin. quant.nosp@m.lib-.nosp@m.users.nosp@m.@lis.nosp@m.ts.sf.nosp@m..net.

Overview

This document summarizes special considerations for compiling QuantLibAddin for OpenOffice.org Calc. The first section gives a general overview relevant to Windows and Linux, this is followed by additional notes specific to compiling on Linux. For further help or to offer feedback on this document send email to quantlib-users@lists.sf.net.

Project Status

The QuantLib Calc Addin is a working prototype, supporting a dozen spreadsheet functions, enough to instantiate some market data objects and then create and price an option. The release includes an example spreadsheet which demonstrates this.

The design of the QuantLibAddin interface is platform independent and the Calc Addin could be extended to include all of the functionality that is currently supported by QuantLibXL.

Compiling QuantLibAddin for OpenOffice.org Calc

Prerequisites

Before compiling an Addin for OOo Calc you'll need to install the OpenOffice.org Software Development Kit (OOo SDK). Make sure you get the version of the OOo SDK that corresponds to the version of OOo which you have installed. QuantLibAddin 1.22.0 has been tested against OOo/OOo SDK version 2.4.0.

Environment Variables

After installing the above, ensure that the following environment variables are set:

variable: OFFICE_PROGRAM_PATH
description: location of OOo program directory
value on Linux: /usr/openoffice.org/program
value on Windows: C:\Program Files\OpenOffice.org 2.4\program

variable: OFFICE_SDK_PATH
description: location of OOo SDK
value on Linux: /usr/openoffice.org/sdk
value on Windows: C:\OpenOffice.org_2.4_SDK

variable: PATH
description: Must include location of OOo SDK bin directory
value on Linux: /usr/openoffice.org/sdk/linux/bin
value on Windows: C:\OpenOffice.org_2.4_SDK\windows\bin

Build

Below are the steps required to compile and install an Addin for OpenOffice.org Calc (Windows and Linux). These steps have been incorporated into the QuantLibAddin Calc makefiles for supported compilers/platforms.

  • idlc - Run OOo utility idlc to compile the idl (interface definition language) file QuantLibAddinCalc.idl into urd (UNO reflection data) file QuantLibAddinCalc.urd. The urd file comprises binary descriptions of the types in the Addin.
  • regmerge - Run OOo utility regmerge to merge the urd file into rdb (registry database) file QuantLibAddinCalc.rdb. The rdb is used by OOo at runtime to infer the functionality available in the Addin.
  • cppumaker - Run OOo utility cppumaker to generate the source code corresponding to the definitions in the rdb.
  • compile - Compile the Addin, including the source generated above, plus the function implementation source code supplied for the Addin. The Addin is compiled into a shared library, i.e. QuantLibAddinCalc-vc71-mt-1_22_0.dll (Windows) or libQuantLibAddinCalc-1.22.0.so (Linux).
  • install - Copy the Addin's shared library and registry database to the OOo program directory.

One further step is required, the name of the registry database must be added to an OOo ini file in order to inform OOo of the location of the Addin. This step is not automated by the build process and must be performed manually:

  • Go to the OOo program directory
  • In a text editor, open the unorc file (unorc on Linux, unorc.ini on Windows)
  • On the line for UNO_SERVICES, append the text
    ORIGIN/QuantLibAddinCalc-vc71-mt-1_22_0.rdb
    
  • On the line for UNO_TYPES, append the text
    $ORIGIN/QuantLibAddinCalc-vc71-mt-1_22_0.rdb
    

Once everything is in place, launch OOo Calc and hit Ctrl-F2 to bring up the list of available functions, if all has gone well the QuantLibAddin functions should appear. The example workbook is

QuantLibAddin\Clients\Calc\Option.ods

Compiling Under Windows

Note that to compile QuantLibAddin for Calc under Windows, you need VC7 (Microsoft Visual C++ 2003). Use solution QuantLibAddinCalc_vc7.sln, configuration Release. You will need to configure VC7 so that the paths it searches for executables include

C:\Program Files\OpenOffice.org_2.4_SDK\windows\bin
C:\Program Files\OpenOffice.org 2.4\program

Additional Considerations for Linux Builds

Compiler

OOo ships with its own versions of certain C/C++ runtime libraries, these are installed to the OOo program directory and OOo loads these in preference to those installed on your system. Therefore the Calc Addin should be compiled with the same version of gcc that was used to compile OOo itself. For a listing of the OOo compiler versions by environment see http://wiki.services.openoffice.org/wiki/Compiler_versions_used_by_port_maintainers_and_release_engineers.

Some additional detail on this issue is available at the following link on the OOo website: Coping with GCC Incompatibilities

Building gcc

If the required version of gcc is not shipped with your distribution then you'll need to install it alongside your existing version of gcc. If you're lucky, the required version of gcc may be available as a binary installation for your distro. More likely you will need to build gcc from source. The gcc source tarballs can be acquired from one of the gcc mirror sites.

See the following document describing the procedure for maintaining multiple versions of gcc concurrently: Installing and Using Multiple Versions of GCC. See also the standard gcc installation notes: Installing GCC.

Building QuantLibAddin for OOo Calc on Linux

You need to build and install the following projects:

  • QuantLib
  • log4cxx
  • ObjectHandler
  • QuantLibAddin

If you have installed a second version of gcc as described above then you need to pass the relevant arguments to configure e.g:

./configure \
CXX=/usr/local/gcc/[version]/bin/g++ \
CPP=/usr/local/gcc/[version]/bin/cpp

... where [version] is the version number of gcc required by Calc on your platform.

NB If you intend to debug QuantLibAddin with the gdb command line debugger, then you should also use the compile flag -gdwarf-2 as explained in this FAQ item: 6.2 How do I debug a QuantLibAddin Linux executable at the command line?

Shared Libraries

At startup OOo loads the QuantLibAddin library, which in turn has a runtime dependency on the shared libraries for QuantLib and ObjectHandler.

The QuantLibAddin Calc binary is always installed to the OOo program directory /usr/lib/openoffice.org2.0/program. QuantLib and ObjectHandler are by default installed to /usr/local/lib, though you may choose to override this when configuring these applications.

You need to configure your system to tell your program loader the location of all relevant shared libraries. One way to accomplish this is to add the relevant paths to the file /etc/ld.so.conf, which tells the loader where to search for shared libraries. After editing this file remember to run ldconfig (as root, no arguments) to refresh the linker cache.

For additional information on managing shared libraries, consult the Program Library HOWTO.