[metapost] mpost interactive prompt

luigi scarso luigi.scarso at gmail.com
Fri Nov 25 15:34:04 CET 2016


On Fri, Nov 25, 2016 at 12:43 PM, Nicola <nvitacolonna at gmail.com> wrote:
> On 25/11/2016 11:49, luigi scarso wrote:
>>
>> On Fri, Nov 25, 2016 at 11:16 AM, Nicola <nvitacolonna at gmail.com> wrote:
>>>
>>> On 25/11/2016 10:36, Nicola wrote:
>>>
>>>> gcc-6  -L./1.9991/build/texk/web2c -L./1.9991/build/libs/pixman -lgmp
>>>> \ -lmplib -lcairo -lpng -lmpfr -lmputil -lz -lpixman -I./1.9991/buil
>>>> \ /texk/web2c/ main.c
>>>
>>>
>>>
>>> Sorry, the command got garbled. This is it:
>>>
>>> gcc-6 -L./1.9991/build/texk/web2c -L./1.9991/build/libs/pixman \
>>>   -lgmp -lmplib -lcairo -lpng -lmpfr -lmputil -lz -lpixman \
>>>   -I./1.9991/build/texk/web2c/ main.c
>>
>>
>>
>> gcc -I./build/texk/web2c/ -L./build/texk/web2c -L./build/libs/pixman
>> main.c build/texk/web2c/libmplib.a build/texk/web2c/libmputil.a
>> build/libs/libpng/libpng.a build/texk/kpathsea/.libs/libkpathsea.a -o
>> main  -lgmp  -lcairo  -lmpfr  -lz -lpixman  -lm
>
>
> Ah ok, libkpathsea was hidden. Thanks, that got me up and running.
>
> Now, I have to figure out why it doesn't find a plain mem file. I have
> added:
>
>   opt->ini_version = 0;
>   opt->mem_name = "plain";
>
> but it says "I can't find the 'plain' preload file!". Do I just need to
> dig more into the documentation?
>
> Nicola
>
>
> --
> http://tug.org/metapost/

#include "mplib.h"
int main (int argc, char **argv) {
  MP mp;
  MP_options *opt = mp_options();
  opt->command_line = argv[1];
  opt->ini_version = 0;
  opt->mem_name =  "mpost";
  mp = mp_initialize(opt);
  if (mp) {
    int history = mp_run(mp);
    mp_finish(mp);
    exit (history);
  } else {
    exit (EXIT_FAILURE);
  }
}

then copy texmf-dist/metapost/base/mpost.mp in the same location of main.
You can use kpathsea to locate the file.

Hint:
compile mpost and main with debug symbols


export CFLAGS='-O0 -ggdb -g3'
./build.sh --parallel  --nostrip


gcc -O0 -ggdb -g3  -I./build/texk/web2c/ -L./build/texk/web2c
-L./build/libs/pixman main.c build/texk/web2c/libmplib.a
build/texk/web2c/libmputil.a build/libs/libpng/libpng.a
build/texk/kpathsea/.libs/libkpathsea.a -o main  -lgmp  -lcairo
-lmpfr  -lz -lpixman  -lm

You can use gdb to go on step by step.
-- 
luigi


More information about the metapost mailing list