Working with LibreOffice SDK Examples

Do you want to write a program that uses LibreOffice to convert different formats, or otherwise work with LibreOffice from another process? A solution would be using LibreOffice SDK.

In order to use the SDK with a binary installation of LibreOffice, you have to install it first from the “SDK and Source code” section of the LibreOffice download page. Otherwise, if you are building LibreOffice from the source, you have to use --enable-odk in order to be able to use SDK.

There are many examples in the SDK, that are good to understand and get an idea of it:

https://api.libreoffice.org/examples/examples.html

In order to use the SDK with a binary installation, do these steps: First, go to the SDK directory, then set environment variables, and then go the directory of the specific example, run make, and then appropriate make run.

$ cd /opt/libreoffice7.2/sdk/
$ ./setsdkenv_unix
************************************************************************
*
* SDK environment is prepared for Linux
*
* SDK = /opt/libreoffice7.2/sdk
* Office = /opt/libreoffice7.2/sdk/..
* Make = /usr/bin
* Zip = /usr/bin
* cat = /usr/bin
* sed = /usr/bin
* C++ Compiler = /usr/bin
* Java = /usr
* SDK Output directory = /home/hossein/libreoffice7.2_sdk
* Auto deployment = YES
*
************************************************************************

$ cd examples/DevelopersGuide/OfficeDev
$ make
...
----------------------------------------------------------------------------
Please use the following commands to execute the examples!
make ContextMenuInterceptor.run
make Number_Formats.run
----------------------------------------------------------------------------

Then you should invoke the appropriate make run command. For example, make ContextMenuInterceptor.run.

When building from the source, you have to go to the instdir/sdk folder, and to the same things.

More information about ContextMenuInterceptor can be found in the OpenOffice Developers’ Guide and in “Intercepting Context Menus” section.

Make sure that you look at the examples that are available in the sdk/examples folder of the LibreOffice installation. Examples are in different languages, including Java, C++, Python, BASIC, C# and VB.NET.

It is also possible to run the examples using modern build tools like cmake and qmake. If you prefer these build tools, you should see this presentation:

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

Presentation: LibreOffice SDK Examples Overhaul Hossein Nourikhah

This talk was recorded presented in the LibreOffice Conference 2021 (LibOCon 2021)

Slides
sdk-examples