Compiling LCDF Typetools under Windows using MinGW

Introduction

This is just a short post to share a workaround to a problem I ran into when building Eddie Kohler’s superb LCDF Typetools under Windows using MinGW. After running ./configure to create the make files I hit a problem during compilation with lots of error messages referring to undefined reference to `ntohl@4'


../typetools/libefont/otf.cc:863: undefined reference to `ntohl@4'
../typetools/libefont/otf.cc:861: undefined reference to `ntohs@4'
../typetools/libefont/otf.cc:861: undefined reference to `ntohs@4'

One solution

The cause of the error is failure to link to the library libwsock32.a (contained in the c:\MinGW\lib\ directory on my PC). The following workaround solves the problem but I’m sure there are better ways of doing it. Several tools within the Typetools collection depend on libwsock32.a to compile successfully. There are:

  • otfinfo
  • otftotfm
  • cfftot1

To build these programs you need to make a small edit to the generated makefiles.

  1. Create a directory called (say) libs within the Typetools directory tree.
  2. Copy libwsock32.a into that directory.
  3. For each application listed above, that depends on libwsock32.a, open the makefile in the appropriate application directory and look for a line starting with XXXXX_LDADD where XXXX is otfinfo or otftotfm or cfftot1
  4. Edit that line to include libwsock32.a
  5. Example: cfftot1_LDADD = ../libefont/libefont.a ../libs/libwsock32.a ../liblcdf/liblcdf.a

You should now be able to run make and achieve a successful compilation. It worked for me, I hope it works for you.