Compiling HTK 3.4 on Windows XP
Wednesday, 14th October, 2009
[This post is from my old blog, originally posted Monday 30th July 2007. As it is still read, I have moved it here with no revisions]
- Using cygwin
- Using visual studio express
Here are some notes on my experiences of compiling HTK 3.4 on Windows XP. I compiled HTK successfully, but some research and experiment was necessary. In the end I tried and was successful with Cygwin and with Visual Studio Express. I hope you find these notes useful.
The issues addressed here will obtain whether you’re using the makefiles that come bundled in the htk3.4 zipfile or the winmakefiles makefiles refered to by Anna Langley in her 02/02/07 post to htk-users.
The source files have multiple carriage returns (‘\r’) at line ends. This upsets both make (cygwin) and nmake (VSE). Nmake appears to think the files are in Mac format and won’t touch them. I don’t know why this spurious whitespace is there, or why it should cause such problems. In any case, the first step is to strip out these characters from all source files. Write a little script in your favourite language, or use this Python script:
#! /usr/bin/python import os def convert(fn): data = open(fn).read().replace('\\r\\r', '') open(fn, 'w').write(data) def main(dataDir): for root, dirs, files in os.walk(dataDir): for fn in files: fullFn = os.path.join(root, fn) convert(fullFn) if __name__ == '__main__': dataDir = 'HTK-3.4/htk/' main(dataDir)
You’ll need Cygwin, of course, and make sure you have installed gcc (which might not be included by default).
The only changes to the source code I found necessary (apart from the line-end changes above), were those pointed out by Mark Huckvale of UCL in his HTK howto.
Change HTKTools/Makefile line 55f
%: %.c $(HTKLIB) if [ ! -d $(bindir) -a X_ = X_yes ] ; then mkdir -p $(bindir) ; fi if [ x$@ = xHSLab ] ; then $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) -lX11 ; else $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) ; fi</pre>
%: %.c $(HTKLIB) if [ ! -d $(bindir) -a X_ = X_yes ] ; then mkdir -p $(bindir) ; fi if [ x$@ = xHSLab ] ; then $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) ; else $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) ; fi</pre>
$ cd HTKLib $ cp HGraf.c HGraf.c.original $ cp HGraf.null.c HGraf.c $ cd ..</pre>
HTK should now compile with ./configure; make; make install as in the README.
HTK is now available only from inside cygwin (e.g., from the cygwin terminal). To make HTK available from the rest of Windows you need to put two things on your PATH:
- the path to the HTK bin files (e.g.: C:\cygwin\usr\local\bin);
- the path to the cygwin1.dll (i.e.: C:\cygwin\bin)
Once you’ve put these on your PATH, you should be able to call HTK commands from the Command Prompt window (or anywhere else).
Download and install the following (go to the Microsoft VS Express download page and follow the instructions):
- Visual C++ 2005 Express Edition.
- Visual Studio Express Editions 2005 Service Pack 1.
- Microsoft Platform SDK for Microsoft Visual C++ 2005 Express.
n.b.: These are large downloads. Download requires registration.
Make sure the bin/, lib/ & include/ directories of the MS Platform SDK are in your PATH.
Everything should now work as in the README. However, if you get an error message like the following:
C:..htkHTKLib>nmake /f htk_htklib_nt.mkf all <.../> Microsoft (R) Program Maintenance Utility Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. lib /OUT:HTKLib.win32.lib esig_asc.obj esig_edr.obj esignal.obj esig_nat.obj HAdapt.obj HAudio.obj HDict.obj HFB.obj HGraf.null.obj HLabel.obj HLat.obj HLM.obj HMap.obj HMath.obj HMem.obj HModel.obj HNet.obj HParm.obj HRec.obj HShell.obj HSigP.obj HTrain.obj HUtil.obj HVQ.obj HWave.obj strarr.obj HExactMPE.obj HFBLat.obj HArc.obj Microsoft (R) Library Manager Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. esig_asc.obj : fatal error LNK1107: invalid or corrupt file: cannot read at 0x1776 NMAKE : fatal error U1077: '"C:Program FilesMicrosoft Visual Studio 8VCBINlib.EXE"' : return code '0x453' Stop.
C:\path\to\htk\HTKLib>nmake /f htk_htklib_nt.mkf clean
And then run your original make again.
HTK will compile on Windows, as long as care is taken over the initial set-up. I hope these notes make that set-up easier.