I'd like to convert some Tex-and-friends code to C, so that I can play with modifying it. As I understand it, the process is:

(1) The tangle utility converts foo.web to a foo.p (Pascal) file, and then

(2) I use web2c to convert foo.p to foo.c

I have managed to make step #1 work, but I'm stuck on step #2. I found the "convert" function and it's components in .../texk/web2c/web2c (in the Live Tex distribution). I was hoping that I could just switch to that directory and type "make" to compile/build the web2c utility. But this directory does not contain a typical Makefile. It has Makefile.am and Makefile.in, but these don't seem to do any compilation, as far as I can see (though I know very little about make files).

So, the questions are:

(1) Is there somewhere I can get a pre-built web2c conversion tool (for Windows), or

(2) Can someone give me good instructions for building it myself.

Edit: Even better ...

(3) Is there somewhere I can get C code for TeX and Metafont. This code is produced as part of the TeX build process, but apparently it must get thrown away after compilation, since I can't seem to find it anywhere.

Edit: Regarding approach #3, I looked at Y&Y TeX, LuaTex, and CXTeX. They have C code, but, as far as I can see, none of them include Metafont, which is the subsystem that most interests me.

Results from typing "Build":

configure: WARNING: Sorry, neither Carbon framework nor fontconfig library: disabling xetex
configure: error: terminating.
=== configuring in web2c failed

And in config.log, I found:

configure:18449: checking for installed fontconfig headers and library
configure:18482: gcc -o conftest.exe -g -O2    conftest.c -lfontconfig  >&5
conftest.c:48:35: fatal error: fontconfig/fontconfig.h: No such file or directory
compilation terminated.
configure:18482: $? = 1
configure: failed program was:
| /* confdefs.h */

But, as Khaled pointed out, I could have avoided building these components, anyway, if I'd done a bit more research.

Avoiding the Above Error In case it helps any of my fellow neophytes and idiots ...

The error arises because fontconfig is missing. The "prerequisites" section of the build instructions tells you how to avoid this. You have to use

  • 1
    There is "configure" and "configure.ac". I'm looking at the TeX Live source, but switching to some source distro would be fine if it would make things easier. Thanks.
    – bubba
    Nov 24, 2012 at 2:16
  • 4
    If you built TeX Live with the included Build script, the converted files should be under Work/texk/web2c/; there you will find tex0.c, mf0.c etc. but I don’t think hacking the generated C files is such a good idea. Nov 24, 2012 at 4:04
  • 3
    You can only build TeX and MetaFont, see README.config for build options (e.g. passing something like --disable-all-pkgs --enable-tex --enable-mf --without-mf-x-toolkit --without-x to configure would do the trick. I put the two files here tex0.c & mf0.c. But if I were you, I’d learn WEB and pascal, actually this exactly what I did to hack LuaTeX (before it was ported to C) and XeTeX. Nov 24, 2012 at 12:49
  • 2
    To get your way around WEB, you should start with webman (I can’t find a PDF file, but just tex it). Nov 24, 2012 at 12:51
  • 1
    Thanks a million, Khaled. You have saved me hours of grief. I wish I'd asked for help here yesterday, before wasting 14 hours of work. With all due respect to DEK (and to you), I can't see learning WEB/pascal in this day and age. I'm a geometry guy, and I think there are some interesting ideas buried within Metafont that I'd like to re-use elsewhere. I'm not a professional programmer, so I need all the help I can get from a modern IDE and modern languages.
    – bubba
    Nov 24, 2012 at 13:09

2 Answers 2


If you built TeX Live with the included Build script, the converted files should be under Work/texk/web2c/; there you will find tex0.c, mf0.c etc. To build only TeX and MetaFont, you can pass something like --disable-all-pkgs --enable-tex --enable-mf --without-mf-x-toolkit --without-x to configure (see README.config for general build option documentation)

All in all, I don’t think hacking the generated C files is such a good idea, it is stripped from all documentations and macros which makes it very hard to read.

There is “a hand-converted C version of TeX” (looks like PDFTeX actually) by Taco Hoekwater here, but no MetaFont. MetaPost has been converted to C for a while now, and so is LuaTeX (both mainly maintained by Taco as well).

  • I couldn't find the "--enable-tex" option, but I was able to build most of tex-live and get the files I wanted. Thanks again.
    – bubba
    Nov 26, 2012 at 8:32

I recently created a (Windows) build of Web2c.exe using Microsoft's Visual Studio and posted some notes describing the process on my blog. To date, I've built tangle and weave from their .web and .ch files: next step TeX! Those notes don't cover every step, but they might help if you want to have a go yourself, whether you are using Windows or Linux. You can find the post here: http://www.readytext.co.uk/?p=2529

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.