KLATEXFORMULA
Home
About
Downloads
Screen Shots
Wiki (Manuals)
News

Devel Manual:KLFBackend Library

From KLFWiki

Jump to: navigation, search

KLFBackend library

The core of KLatexFormula's functionality is provided by the library KLFBackend. This library provides a few very basic functions useful for the whole of KLatexFormula package (common declarations), a few general utilities, and one function called getLatexFormula() which takes care of running latex, dvips, gs and epstopdf to get a QImage, PS and PDF data from a given latex expression and various input settings.

Note: As of KLatexFormula 3.3, the KLFBackend library can no longer be compiled with Qt3; Qt4 is required.

This library is intended of course for use in KLatexFormula itself, but naturally anyone wishing to add to his/her program the functionality of converting latex expressions to images can link the program to the KLFBackend library. A utility to detect where latex/dvips/gs are is provided, with a few hard-coded standard paths, with the option to look into more paths. At the end, this functionality amounts to very little code in your program.

View the complete API Documentation.

KLFBackend depends on some utilities which are defined in the KLFTools library. However, klatexformula also automatically generates the klfbackend_auto library which is autonomous and includes the (few) relevant sources from klftools internally, thus no longer depending on klftools. In short: if anyway your program depends on KLFTools because you use those tools already, then you link to KLFTools and KLFBackend; if you only wish to link to KLFBackend, then link to klfbackend_auto.

Note: If you want to bundle a distribution of latex with your program, this is possible. However bear in mind that a latex distribution can be heavy (typically in the order of 100MB). For example on windows install the portable version of MikTeX and add/remove packages to customize the installation (to reduce the size, minimal size I achieved=~40MB); on linux you can install a customized texlive installation.

Since Version 3.2

When compiling, you may choose at the cmake stage whether to build a static or a shared library. See User Manual:CMake compilation options.

Example:

cmake -DKLF_QT_VERSION=4 -DKLF_LIBKLFBACKEND_STATIC=FALSE    # build shared Qt4 version

The library is called libklfbackend.so or libklfbackend.a.

Versions 3.0 and 3.1

When compiling, you may choose at the qmake stage whether you want a static or a shared library. Similarly, you may choose to compile the backend library for Qt 3 or Qt 4. See User Manual:qmake compilation options for more specific information on these options. In short, running

> qmake BACKEND_ONLY=true BACKEND_USE_QT4=true BACKEND_SHAREDORSTATIC=dll

will compile a library named libklfbackend.so depending on Qt 4, while the command

> qmake BACKEND_ONLY=true BACKEND_USE_QT4=false BACKEND_SHAREDORSTATIC=dll

will compile a library named libklfbackend-qt3.so linked to the Qt 3 library.