[metapost] Trying to figure out MPLib

Taco Hoekwater taco at elvenkind.com
Fri Aug 3 09:47:08 CEST 2012


Hi,

On 08/03/2012 08:37 AM, Shriramana Sharma wrote:
>
> Can anyone please help me with this? Do I need to load the plain file
> or something? How to do that? Do I need to first input a \relax
> command before starting with beginfig() and stuff? Please help.
> Thanks!

Yes, if you want to use macros like beginfig(), you have to load
plain.mp. You could just copy plain.mp to the same directory
and change command to:
	
   "input plain; beginfig ( 1 ) ; dra... "

MPlib will find files in the current directory or with a full
path name automatically. If the file is not in the current
directory, you have to add a file finder function to the MP_options.

You could write your own based on the paths in your project, or you
could use kpathsea.

Attached test.c does a bare-bones version of using kpathsea; to
compile it you need to add the kpathsea include directories to
the compiler command line. I used this:

   gcc -o test test.c -I../../../source/texk -I.. -L . -l mplib -l kpathsea

but that depends on where you are building and where the header
files are, obviously.

If you want more inspiration, just look at mpost.w in the source
tree. The 'mpost' executable is just a C wrapper around libmplib.

Best wishes,
Taco

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 1363 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20120803/c107b874/attachment.bin>


More information about the metapost mailing list