[libvoikko] Namespace collisions in HFST and Lttoolbox

Harri Pitkänen hatapitk at iki.fi
Fri Mar 12 19:28:33 EET 2010

I was trying to build libvoikko with --enable-hfst --enable-lttoolbox and ran 
into multiple problems related to namespace collisions from these packages.

First there is a problem specific to HFST only: When configured using pkg-
config, -I/include/hfst2 is added to CFLAGS. This breaks things because this 
directory contains file "string.h" which now gets included in place of the 
standard C header with the same name. I suppose that the HFST file should be 
included as <hfst2/string.h> and adding the directory to include path is 
unnecessary. The small patch at the end of this message fixes the problem.

Another problem is that both HFST and Lttoolbox introduce some classes in the 
default namespace. Since the libraries serve similar purposes it is not a 
surprise that some of the classes have exactly same names. Here are some 
examples, there might be others too:

/usr/include/lttoolbox-3.1/lttoolbox/alphabet.h:35: error: redefinition of 
‘class Alphabet’
/home/harri/apps/include/hfst2/sfst/alphabet.h:220: error: previous definition 
of ‘class Alphabet’

/usr/include/lttoolbox-3.1/lttoolbox/node.h:107: error: redefinition of ‘class 
/home/harri/apps/include/hfst2/sfst/fst.h:375: error: previous definition of 
‘class Node’

/usr/include/lttoolbox-3.1/lttoolbox/state.h:36: error: redefinition of ‘union 
/home/harri/apps/include/hfst2/hfst.h:12: error: previous definition of ‘union 

For now it is not possible to enable both HFST and Lttoolbox backends 
simultaneously in libvoikko due to these collisions.

I have CCd hfst-bugs but have not yet reported this to Apertium bug tracker. 
I'll do that later unless someone here wants to take care of this issue for 


Index: hfst/hfst.pc.in
--- hfst/hfst.pc.in     (revision 275)
+++ hfst/hfst.pc.in     (working copy)
@@ -7,4 +7,4 @@
 Description: Finite-state transducer library bridge for multiple FLOSS 
 Libs: -L${libdir} -l at LIBHFST_NAME@ @LIBS@
-Cflags: -I${includedir}/@LIBHFST_NAME@@LIBHFST_MAJOR@
+Cflags: -I${includedir}

More information about the Libvoikko mailing list