Wednesday, February 3, 2010

How to compile HTK under Visual Studio 2008

This post describes how to compile HTK source code under Visual Studio 2008 on Windows.

0. Download HTK source code for Windows from:
http://htk.eng.cam.ac.uk/download.shtml
and decompress it, after which you can get the following folders:


1. Create a solution named "HTK-windows", and also a project named "HCopy" in VS2008:

and then in the configuration of project "HCopy", you need to click on the box of "Empty project" as follows:



2. Configure the project "HCopy"
You first need to copy the HTKLib folder to the root directory of your solution "HTK-windows", and then copy the file "HCopy.c" in the folder "HTKTools" to the root directory of your project "HCopy".

Right click the project "HCopy", and then click the "Properties" as follows:


In the "Properties" window, you need to add the "HTKLib" folder (or $(SolutionDir)\HTKLib) located in the root directory of your solution, to the "Additional Include Directories":


Then add /D "ARCH=WIN32" to the "Command Line":


3. Add the the files (*.c and *.h) except "HGraf.c" and "HGraf.null.c" in folder "HTKLib" into project "HCopy":




4. Finally, you can build your project "HCopy":


5. Of course, here I only present how to compile HCopy of HTK in VS2008, and you can follow more or less the same procedure to compile other tools of HTK. You just need to create new projects under the solution "HTK-windows" as follows:



PS: if you want to build HSLab.c, you need to exclude HFB.h and HFB.c;
if you want to build HDecode.c, you need to add an additional command line parameter /D "NO_LAT_LM", and also do not add HLM.h and HLM.c to your project "HDecode".