Compilation on MacOS X

OpenFst version 1.4

Version 1.4 requires MacOS X 10.8 or later and Xcode 5. No special instructions needed.

OpenFst versions 1.0 to 1.3.4

This only applies to Tiger and Leopard. On Snow Leopard (10.6), you simply need to use the latest version of Xcode (3.2.3) that ships with gcc 4.2.

Versions 1.0 and later of the OpenFst library cannot be compiled on MacOS X (10.4 Tiger or 10.5 Leopard) using Apple Xcode version of gcc. The reason is that Apple uses gcc 4.0 and this version of gcc has a bug in the copy constructor of TR1's unordered_map. This bug was fixed almost 4 years ago.

We suggest here two different workarounds: 1) using a more recent version of gcc (such as the one provided by Fink or MacPorts) or 2) manually patching the relevant include file in Apple's gcc setup.

Compile the OpenFst library using this version of g++ instead of Apple's. In the openfst-1.0 directory, do:

$ CXX=/sw/bin/g++-4 ./configure
$ make -j 4
$ make check

Fink does not provide pre-compiled versions of gcc for MacOS X 10.4 Tiger but you can install one from source (see Fink's website for more details). An other approach would be to install a working version of gcc using MacPorts.

Patching Apple's gcc 4.0 relevant include file

You can also manually change the buggy include file in Apple's setup.

Download the patched version of tr1/hashtablehere . This file has been updated to fix an other bug preventing compilation of OpenFst 1.2 and above. The following assumes that the file was saved to ~/Downloads/hashtable, replace that by the actual file location (note that your browser might have rename hashtable to hashtable.txt).

(Optional) Check how minimal the change is:

$ diff ~/Downloads/hashtable /usr/include/c++/4.0.0/tr1/hashtable

Overwrite Apple's version with the patched version and restore file permissions and ownership: