OpenFst For Windows Getting Started


This version is known to work under 32bit versions of Microsoft Windows XP or Vista. The Compiler requirements are Visual Studio 2008 (SP1) this includes free C++ express edition available here.


From the contrib section of the OpenFst site download the file.


Unzip in the desired location (for example C:\code ). The files should now be in c:\code\openfstwin\ and from there open the solution file openfstwin.sln in Visual Studio. Select either the Debug or Release build and from the build menu run the Build Solution.

Using The Command Line Tools

The command lines tools and library should now be located in C:\code\openfstwin\Release or C:\code\openfstwin\debug.


Creating a Simple Application

Open Visual Studio and create a new C++ Project. From the New Project Dialog select Project type Win32 and template type Win32 Console Application.


On the next dialog. Uncheck Precompiled header and check Empty Project and Application Type: Console Application.


Add a new C++ file to the project.


Add some code, for example just paste the below

#include <fst/vector-fst.h>
using namespace fst;
int main()
  typedef StdVectorFst::StateId StateId;
  typedef StdVectorFst::Weight Weight;
  StdVectorFst ofst;
  StateId q = ofst.AddState();   
  for(int i=0; i!=10;++i)
      StateId n = ofst.AddState();        
      ofst.AddArc(q, StdArc(i+1, i+1, Weight::One(), n));
      q = n;
  return 0;

Add include and library paths to the project.

Either From the main menu go to Properties -> ProjectName(openfsttest) in this example. Or right click the project node in the solution explorer.

Go to Configuration Properties -> C/C++ -> General and add an additional include directory to the openfst src include directory. Be sure to set Configuraion -> All Configurations in the top left combo box


Next: go to Linker input and add additional dependency to openfstwinlib.lib again set this for all configurations


Finally, Linker->General add Additional Library Directory. Set the correct paths for the Release and Debug Configurations.


Now compile either the Release or Debug from the build menu. It everything went smoothly there should be openfsttest.exe in the Release and or Debug directory. After invoking openfsttest.exe a file names test.ofst should be written to the same directly.

Running the fstprint.exe from the Openfst tools should give the following output:

0       1       1       1

1       2       2       2

2       3       3       3

3       4       4       4

4       5       5       5

5       6       6       6

6       7       7       7

7       8       8       8

8       9       9       9

9       10      10      10


This entry was posted by Edobashira. Bookmark the permalink.

5 thoughts on “OpenFst For Windows Getting Started”

Leave a Reply

Note: only a member of this blog may post a comment.