[metapost] Compile metapost

Taco Hoekwater taco at elvenkind.com
Thu Apr 1 16:34:47 CEST 2010


Dmitry Solomennikov wrote:
> Hello,
> 
> I have an idea to incorporate MP's scanner and math engine into
> CAD-like project. I will produce output by myself. I need
> calculations only: path intersections, equation solvation,
> calculations etc. And I need results of a calculations, that is point
> coords and path information. There are two questions.

> 1) How to build MP as *.dll (win) or *.so (linux)?

Metapost consists of two components: a library and an executable driver.

The library is built from am/libmplib.am, the executable from
am/mplib.am.

The library consists of avl.c, memio.w, mp.w, psout.w, and svgout.w,
   this does all the real work except the TeX connection and file
   searching.
The binary has mpxout.w and mpost.w, and connects the library to
   kpathsea.

There is also lmplib.c. This file creates bindings to the library
component from lua, and could be used as an example. If this is
too obscure for you, see manual/mplibapi.tex for the official
documentation.

The current build system does not support creating a dynamic library
(because it is derived from the TeXLive build system which does not
need that) but the general approach is fairly straightforward:
run 'ctangle' on memio.w, mp.w, psout.w, and svgout.w, then compile
the resulting C files + avl.c into a dynamic library using whatever
methods you need for your platform.

> 2) I don't need an TeX-ability with MP (no texts at all). How to
> build MP without TeX connection (kpathsea and others)?

This is automatic if you only build the library part: when the
relevant callback functions are not set, the library disables
btex .. etex processing and will only be able to use files from
the current working directory.

Best wishes,
Taco


More information about the metapost mailing list