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".

6 comments:

Anonymous said...

Pidong,

Thanks for the very detailed post, the screenshots really helped to know exactly what was going on. I am trying to build HERest individually on VS2008 and everything went fine until the build. I get link errors in a few places like HArc.obj and HFBLat.obj related to _isnan(HArc.obj : error LNK2019: unresolved external symbol _isnan referenced in function _AddArcTrans)

I am sure this is because of some redefinitions or some missing #define 's during the linking, but if you ran into something similar, let me know!

Thanks again for the nice posts and keep em coming!

Rabbit

waheed said...

Can you post any working example of HCopy or any other tool of HTK.

Simon said...
This comment has been removed by the author.
Simon said...
This comment has been removed by the author.
Simon said...

Sure you need to add HCopy.c to the project files as well!

Anonymous said...

Thanks for the tutorial. The code compiles smoothly. The problem is, when I run HVite I get the error:

ERROR [+6306] OpenAsChannel: Audio input not supported

I tried version 3.4.1 and 3.3. Same problem with both.

Any idea?