嵌入式平臺openFst的交叉編譯

該博文屬於系列文章,其他文章參考總覽: kaldi嵌入式平臺的移植及實現

 

前言:

openfst的介紹就不必了,大家自行百度,下面進入正題。

Openfst下載:

目前kaldi版本爲5.5,使用的openfst的版本爲openfst-1.6.7.tar.gz,進入openfst官網,找到對應的tar.gz下載,如下圖

Openfst的交叉編譯:

1. 拷貝openfst-1.6.7.tar.gz至kaldi源碼路徑下的tools/

2. 執行解壓命令 tar -zxvf openfst-1.6.7.tar.gz 

3. cd openfst-1.6.7/

4. 執行命令  CXX=mips-linux-gnu-g++ CXXFLAGS=-mxgot ./configure --prefix=`pwd` --enable-static --enable-shared --enable-ngram-fsts --host=mips-linux-gnu LIBS="-ldl"

5. make 

6. 修改/src/script/Makefile,在CXXFLAGS變量中添加 -G0   ,(注:在寫此博客時,第5步編譯完成後,已經能夠順利編譯成功,則跳過該步。 之前這樣修改可能是由於交叉工具鏈的版本不同,具體編譯錯誤的日誌沒有保存,如果第5步編譯失敗,可以再嘗試這一步後重新編譯)

7. make install

8. 創建軟鏈接: ln -s openfst-1.6.7 openfst

-------------------------------------------------------------------------------------------------------------------------------------------------------------

關於以上命令解釋:

  • --prefix 執行make install時lib庫的安裝位置爲當前位置
  • --enable-static 生成靜態庫  (實際在開發板中,使用的是靜態庫,當然也可以用動態庫)
  • --enable-shared 生成動態庫
  • --enable-ngram-fsts ngram是語言模型相關的,可以查閱ngram相關的資料
  • CXXFLAGS=-mxgot 由於編譯錯誤,具體見下面的報錯

編譯錯誤一:

報錯log: relocation truncated to fit: R_MIPS_CALL16 against `std::allocator<char>::allocator()@@GLIBCXX_3.4',  詳細log如下:

.libs/determinize.o: In function `fst::script::Determinize(fst::script::FstClass const&, fst::script::MutableFstClass*, fst::script::DeterminizeOptions const&)':
determinize.cc:(.text+0x43c): relocation truncated to fit: R_MIPS_CALL16 against `std::allocator<char>::allocator()@@GLIBCXX_3.4'
determinize.cc:(.text+0x46c): relocation truncated to fit: R_MIPS_CALL16 against `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)@@GLIBCXX_3.4.21'
determinize.cc:(.text+0x4d0): relocation truncated to fit: R_MIPS_CALL16 against `std::allocator<char>::allocator()@@GLIBCXX_3.4'
determinize.cc:(.text+0x500): relocation truncated to fit: R_MIPS_CALL16 against `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)@@GLIBCXX_3.4.21'
determinize.cc:(.text+0x56c): relocation truncated to fit: R_MIPS_CALL16 against `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()@@GLIBCXX_3.4.21'
determinize.cc:(.text+0x5b4): relocation truncated to fit: R_MIPS_CALL16 against `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()@@GLIBCXX_3.4.21'
determinize.cc:(.text+0x614): relocation truncated to fit: R_MIPS_CALL16 against `fst::script::MutableFstClass::SetProperties(unsigned long long, unsigned long long)'
determinize.cc:(.text+0x664): relocation truncated to fit: R_MIPS_CALL16 against `std::allocator<char>::allocator()@@GLIBCXX_3.4'
determinize.cc:(.text+0x690): relocation truncated to fit: R_MIPS_CALL16 against `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)@@GLIBCXX_3.4.21'
determinize.cc:(.text+0x6f0): relocation truncated to fit: R_MIPS_CALL16 against `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()@@GLIBCXX_3.4.21'
.libs/determinize.o: In function `__static_initialization_and_destruction_0(int, int)':
determinize.cc:(.text+0x7c0): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Makefile:445: recipe for target 'libfstscript.la' failed
make[3]: *** [libfstscript.la] Error 1

解決方法:第4步中在變量CXXFLAGS中添加 -mxgot ,即 CXXFLAGS=-mxgot

 

如果有編譯問題,歡迎留言,一起研究解決方法。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章