FST compile error

548 views
Skip to first unread message

Cemil Demir

unread,
Mar 21, 2016, 7:49:28 AM3/21/16
to kaldi...@googlegroups.com
Hi,

I applied patches and i have compiled Kaldi with Openfst 1.4.1 version. There is no problem in compilation.

I compiled Kaldi in shared version. I create my own cpp project and add these shared libraries and include header files in my project.

I could compile the project and run until when i include "fstext/fstext-lib.h".

When i include this library, i took many similar errors. The first one:

"/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:223:34: error: ‘DefaultCacheStateAllocator’ was not declared in this scope"


Do i miss some basic compilation step?

Could you help me?

Thanks.
--

Jan Trmal

unread,
Mar 21, 2016, 7:58:59 AM3/21/16
to kaldi-help

Have a look at the files tools/Makefile and src/kaldi.mk

In the former, the OPENFST_VERSION should be set to 1.4.1 (see the comments)

In the latter, the OPENFST_VER should be set to 1.4.1 and  OPENFST_GE_10400 should be set to 1

While you have to modify manually the file tools/Makefile, the variables in src/kaldi.mk should be set automatically, when you re-run the configure script, I believe. Did you do it?

I suspect you patched and compiled openfst1.4.1 manually, instead of the provided tools/Makefile?

y.


--
You received this message because you are subscribed to the Google Groups "kaldi-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cemil Demir

unread,
Mar 21, 2016, 8:40:19 AM3/21/16
to kaldi...@googlegroups.com
Hi Jan,

I made the compilation as you described. The complete log is:

I also attached the kaldi.mk file. 

Thank you.


cd '/media/kdtm/kdtm_backup/ocr/codes/KaldiApplication'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/media/kdtm/kdtm_backup/ocr/codes/KaldiApplication'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/kaldiapplication
make[2]: Entering directory `/media/kdtm/kdtm_backup/ocr/codes/KaldiApplication'
mkdir -p build/Debug/GNU-Linux/_ext/9f49d292
rm -f "build/Debug/GNU-Linux/_ext/9f49d292/Segment.o.d"
g++    -c -g -DHAVE_ATLAS -DHAVE_CUDA -DHAVE_CXXABI_H -DHAVE_EXECINFO_H=1 -DHAVE_POSIX_MEMALIGN -DKALDI_DOUBLEPRECISION=0 -I. -I/usr/local/cuda-6.5/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/src -I/media/kdtm/kdtm_backup/kaldi/kaldi-trunk_org/tools/ATLAS/include -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/_ext/9f49d292/Segment.o.d" -o build/Debug/GNU-Linux/_ext/9f49d292/Segment.o /media/kdtm/kdtm_backup/ocr/codes/KaldiApplication/Segment.cpp
mkdir -p build/Debug/GNU-Linux/_ext/9f49d292
rm -f "build/Debug/GNU-Linux/_ext/9f49d292/Segments.o.d"
g++    -c -g -DHAVE_ATLAS -DHAVE_CUDA -DHAVE_CXXABI_H -DHAVE_EXECINFO_H=1 -DHAVE_POSIX_MEMALIGN -DKALDI_DOUBLEPRECISION=0 -I. -I/usr/local/cuda-6.5/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/src -I/media/kdtm/kdtm_backup/kaldi/kaldi-trunk_org/tools/ATLAS/include -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/_ext/9f49d292/Segments.o.d" -o build/Debug/GNU-Linux/_ext/9f49d292/Segments.o /media/kdtm/kdtm_backup/ocr/codes/KaldiApplication/Segments.cpp
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
g++    -c -g -DHAVE_ATLAS -DHAVE_CUDA -DHAVE_CXXABI_H -DHAVE_EXECINFO_H=1 -DHAVE_POSIX_MEMALIGN -DKALDI_DOUBLEPRECISION=0 -I. -I/usr/local/cuda-6.5/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/src -I/media/kdtm/kdtm_backup/kaldi/kaldi-trunk_org/tools/ATLAS/include -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:23:0,
                 from main.cpp:32:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:223:34: error: ‘DefaultCacheStateAllocator’ was not declared in this scope
                                  DefaultCacheStateAllocator<CacheState<Arc> > >;
                                  ^
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:223:77: error: wrong number of template arguments (2, should be 1)
                                  DefaultCacheStateAllocator<CacheState<Arc> > >;
                                                                             ^
In file included from /usr/local/include/fst/compact-fst.h:32:0,
                 from /usr/local/include/fst/fstlib.h:54,
                 from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:22,
                 from main.cpp:32:
/usr/local/include/fst/cache.h:1203:7: error: provided for ‘template<class F> class fst::CacheArcIterator’
 class CacheArcIterator {
       ^
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:23:0,
                 from main.cpp:32:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:223:79: error: expected unqualified-id before ‘>’ token
                                  DefaultCacheStateAllocator<CacheState<Arc> > >;
                                                                               ^
In file included from /usr/local/include/fst/compact-fst.h:32:0,
                 from /usr/local/include/fst/fstlib.h:54,
                 from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:22,
                 from main.cpp:32:
/usr/local/include/fst/cache.h: In instantiation of ‘class fst::CacheStateIterator<fst::ContextFst<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int> >’:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:345:7:   required from ‘class fst::StateIterator<fst::ContextFst<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int> >’
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:373:14:   required from ‘void fst::ContextFst<Arc, LabelT>::InitStateIterator(fst::StateIteratorData<A>*) const [with Arc = fst::ArcTpl<fst::TropicalWeightTpl<float> >; LabelT = int]’
main.cpp:133:1:   required from here
/usr/local/include/fst/cache.h:1151:29: error: no type named ‘Store’ in ‘class fst::ContextFst<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int>’
   typedef typename F::Store Store;
                             ^
/usr/local/include/fst/cache.h:1154:39: error: no type named ‘Store’ in ‘class fst::ContextFst<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int>’
   typedef CacheBaseImpl<State, Store> Impl;
                                       ^
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:535:0,
                 from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:23,
                 from main.cpp:32:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst-inl.h: In instantiation of ‘fst::ContextFstImpl<Arc, LabelT>::StateId fst::ContextFstImpl<Arc, LabelT>::FindState(const std::vector<B>&) [with Arc = fst::ArcTpl<fst::TropicalWeightTpl<float> >; LabelT = int; fst::ContextFstImpl<Arc, LabelT>::StateId = int]’:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst-inl.h:78:30:   required from ‘fst::ContextFstImpl<Arc, LabelT>::StateId fst::ContextFstImpl<Arc, LabelT>::Start() [with Arc = fst::ArcTpl<fst::TropicalWeightTpl<float> >; LabelT = int; fst::ContextFstImpl<Arc, LabelT>::StateId = int]’
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:249:55:   required from ‘fst::ContextFst<Arc, LabelT>::StateId fst::ContextFst<Arc, LabelT>::Start() const [with Arc = fst::ArcTpl<fst::TropicalWeightTpl<float> >; LabelT = int; fst::ContextFst<Arc, LabelT>::StateId = int]’
main.cpp:133:1:   required from here
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst-inl.h:46:60: error: ‘AddState’ is not a member of ‘fst::CacheImpl<fst::ArcTpl<fst::TropicalWeightTpl<float> > >’
     StateId this_state_id_check = CacheImpl<Arc>::AddState();
                                                            ^
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:535:0,
                 from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:23,
                 from main.cpp:32:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst-inl.h: In instantiation of ‘void fst::ContextFstImpl<Arc, LabelT>::Expand(fst::ContextFstImpl<Arc, LabelT>::StateId) [with Arc = fst::ArcTpl<fst::TropicalWeightTpl<float> >; LabelT = int; fst::ContextFstImpl<Arc, LabelT>::StateId = int]’:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst-inl.h:208:13:   required from ‘size_t fst::ContextFstImpl<Arc, LabelT>::NumInputEpsilons(fst::ContextFstImpl<Arc, LabelT>::StateId) [with Arc = fst::ArcTpl<fst::TropicalWeightTpl<float> >; LabelT = int; size_t = long unsigned int; fst::ContextFstImpl<Arc, LabelT>::StateId = int]’
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:268:37:   required from ‘size_t fst::ContextFst<Arc, LabelT>::NumInputEpsilons(fst::ContextFst<Arc, LabelT>::StateId) const [with Arc = fst::ArcTpl<fst::TropicalWeightTpl<float> >; LabelT = int; size_t = long unsigned int; fst::ContextFst<Arc, LabelT>::StateId = int]’
main.cpp:133:1:   required from here
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst-inl.h:331:5: error: ‘class fst::ContextFstImpl<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int>’ has no member named ‘AddArc’
     this->AddArc(s, arc);
     ^
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst-inl.h:341:7: error: ‘class fst::ContextFstImpl<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int>’ has no member named ‘AddArc’
       this->AddArc(s, arc);
       ^
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst-inl.h:352:7: error: ‘class fst::ContextFstImpl<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int>’ has no member named ‘AddArc’
       this->AddArc(s, arc);
       ^
make[2]: *** [build/Debug/GNU-Linux/main.o] Error 1
make[2]: Leaving directory `/media/kdtm/kdtm_backup/ocr/codes/KaldiApplication'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/media/kdtm/kdtm_backup/ocr/codes/KaldiApplication'
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 4s)

--
kaldi.mk

Jan Trmal

unread,
Mar 21, 2016, 9:16:12 AM3/21/16
to kaldi-help
See this:
/usr/local/include/fst/cache.h:1203:7: error: provided for ‘template<class F> class fst::CacheArcIterator’
vs
./configure --shared --cudatk-dir=/usr/local/cuda-6.5 --fst-root=/media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1

the FST include has different path. Perhaps you have installed system-wide fst of different/incompatible version?

Also, 
the kaldi.mk seems to be completely unrelated to the log messages.

see
g++    -c -g -DHAVE_ATLAS -DHAVE_CUDA -DHAVE_CXXABI_H -DHAVE_EXECINFO_H=1 -DHAVE_POSIX_MEMALIGN -DKALDI_DOUBLEPRECISION=0 -I. -I/usr/local/cuda-6.5/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/src -I/media/kdtm/kdtm_backup/kaldi/kaldi-trunk_org/tools/ATLAS/include -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:23:0,

There is no main.cpp in kaldi and in kaldi.mk we set 
a) -std=c++0x
b) -DHAVE_OPENFST_GE_10400

So I don't believe much this is genuine kaldi issue. More like a failure of build something that might be build on the top of kaldi.

y.

Cemil Demir

unread,
Mar 21, 2016, 9:30:51 AM3/21/16
to kaldi...@googlegroups.com
I think, i could not express myself clearly. I could compile Kaldi source code and obtain executables. 

I want to use the shared library files of Kaldi in my own cpp project. Except Openfst related libraries, i have no problem and i can use shared library files in my project. 

However, when i add a header file related to Openfst, i take a  compilation error. 

Yes, you are right, in the previous e-mail, i used the wrong include library for Openfst. Now, i fix this issue, but nothing is changed.

The log message of my own program compilation is below.

Dou you have any idea about this?

Thank you.

cd '/media/kdtm/kdtm_backup/ocr/codes/KaldiApplication'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/media/kdtm/kdtm_backup/ocr/codes/KaldiApplication'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/kaldiapplication
make[2]: Entering directory `/media/kdtm/kdtm_backup/ocr/codes/KaldiApplication'
mkdir -p build/Debug/GNU-Linux/_ext/9f49d292
rm -f "build/Debug/GNU-Linux/_ext/9f49d292/Segment.o.d"
g++    -c -g -DHAVE_ATLAS -DHAVE_CUDA -DHAVE_CXXABI_H -DHAVE_EXECINFO_H=1 -DHAVE_POSIX_MEMALIGN -DKALDI_DOUBLEPRECISION=0 -I. -I/usr/local/cuda-6.5/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/src -I/media/kdtm/kdtm_backup/kaldi/kaldi-trunk_org/tools/ATLAS/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/_ext/9f49d292/Segment.o.d" -o build/Debug/GNU-Linux/_ext/9f49d292/Segment.o /media/kdtm/kdtm_backup/ocr/codes/KaldiApplication/Segment.cpp
mkdir -p build/Debug/GNU-Linux/_ext/9f49d292
rm -f "build/Debug/GNU-Linux/_ext/9f49d292/Segments.o.d"
g++    -c -g -DHAVE_ATLAS -DHAVE_CUDA -DHAVE_CXXABI_H -DHAVE_EXECINFO_H=1 -DHAVE_POSIX_MEMALIGN -DKALDI_DOUBLEPRECISION=0 -I. -I/usr/local/cuda-6.5/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/src -I/media/kdtm/kdtm_backup/kaldi/kaldi-trunk_org/tools/ATLAS/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/_ext/9f49d292/Segments.o.d" -o build/Debug/GNU-Linux/_ext/9f49d292/Segments.o /media/kdtm/kdtm_backup/ocr/codes/KaldiApplication/Segments.cpp
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
g++    -c -g -DHAVE_ATLAS -DHAVE_CUDA -DHAVE_CXXABI_H -DHAVE_EXECINFO_H=1 -DHAVE_POSIX_MEMALIGN -DKALDI_DOUBLEPRECISION=0 -I. -I/usr/local/cuda-6.5/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/src -I/media/kdtm/kdtm_backup/kaldi/kaldi-trunk_org/tools/ATLAS/include -I/media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:23:0,
                 from main.cpp:32:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:223:34: error: ‘DefaultCacheStateAllocator’ was not declared in this scope
                                  DefaultCacheStateAllocator<CacheState<Arc> > >;
                                  ^
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:223:77: error: wrong number of template arguments (2, should be 1)
                                  DefaultCacheStateAllocator<CacheState<Arc> > >;
                                                                             ^
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include/fst/compact-fst.h:32:0,
                 from /media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include/fst/fstlib.h:54,
                 from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:22,
                 from main.cpp:32:
/media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include/fst/cache.h:1203:7: error: provided for ‘template<class F> class fst::CacheArcIterator’
 class CacheArcIterator {
       ^
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:23:0,
                 from main.cpp:32:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:223:79: error: expected unqualified-id before ‘>’ token
                                  DefaultCacheStateAllocator<CacheState<Arc> > >;
                                                                               ^
In file included from /media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include/fst/compact-fst.h:32:0,
                 from /media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include/fst/fstlib.h:54,
                 from /media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/fstext-lib.h:22,
                 from main.cpp:32:
/media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include/fst/cache.h: In instantiation of ‘class fst::CacheStateIterator<fst::ContextFst<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int> >’:
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:345:7:   required from ‘class fst::StateIterator<fst::ContextFst<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int> >’
/media/kdtm/kdtm_backup/kaldi/kaldi/src/fstext/context-fst.h:373:14:   required from ‘void fst::ContextFst<Arc, LabelT>::InitStateIterator(fst::StateIteratorData<A>*) const [with Arc = fst::ArcTpl<fst::TropicalWeightTpl<float> >; LabelT = int]’
main.cpp:133:1:   required from here
/media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include/fst/cache.h:1151:29: error: no type named ‘Store’ in ‘class fst::ContextFst<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int>’
   typedef typename F::Store Store;
                             ^
/media/kdtm/kdtm_backup/kaldi/kaldi/tools/openfst-1.4.1/include/fst/cache.h:1154:39: error: no type named ‘Store’ in ‘class fst::ContextFst<fst::ArcTpl<fst::TropicalWeightTpl<float> >, int>’
kaldi.mk

Jan Trmal

unread,
Mar 21, 2016, 9:51:54 AM3/21/16
to kaldi-help

You have to define OPENFST_GE_10400  (i.e. add -DOPENFST_GE_10400 to the command line, similarly to -DKALDI_DOUBLEPRECISION=0

In cases when you have compilation issues with custom code you build on the top of a toolkit that compiles OK, you should

a) look at the command line of the original toolkit and try to figure out which compiler flags you have different or missing.

b) state it explicitly when you are asking someone else (because it usually suggests a different set of possible issues)

y.

Jan Trmal

unread,
Mar 22, 2016, 8:43:40 AM3/22/16
to kaldi-help
I apologize -- the correct variable name is HAVE_OPENFST_GE_10400 (i.e. add -DHAVE_OPENFST_GE_10400 to the gcc flags)
y.

Cemil Demir

unread,
Mar 22, 2016, 9:13:23 AM3/22/16
to kaldi...@googlegroups.com
Hi Jan,

Yes you're right. I could compile my code.

Thank you.
Reply all
Reply to author
Forward
0 new messages