基本的节日计划有未定义的参考错误

时间:2017-11-13 19:59:21

标签: c++ text-to-speech undefined-reference festival

我目前正在尝试编制这个基本的节日节目

#include <iostream>
#include <festival/festival.h>

#define HEAP_SIZE 210000
#define LOAD_INIT_FILES 1

using namespace std;


int main()
{
    festival_initialize(LOAD_INIT_FILES, HEAP_SIZE);

    festival_say_text("Hello World");

    festival_wait_for_spooler();

    return 0;
}

当我尝试用g ++构建程序时,我得到了这些错误:

speech_tools/lib/libestools.a $USER/Downloads/festival/speech_tools/lib/libeststring.a
$USER/Downloads/festival/speech_tools/lib/libestools.a(EST_PST.o): In function `EST_PredictionSuffixTree::test(EST_String)':
EST_PST.cc:(.text+0x2d30): undefined reference to `confusion(EST_TKVL<EST_String, EST_String>&, EST_TList<EST_String>&)'
EST_PST.cc:(.text+0x2d40): undefined reference to `print_confusion(EST_FMatrix const&, EST_TKVL<EST_String, EST_String>&, EST_TList<EST_String>&)'
$USER/Downloads/festival/speech_tools/lib/libestools.a(wfst_ops.o): In function `EST_WFST::determinize(EST_WFST const&)':
wfst_ops.cc:(.text+0x1136): undefined reference to `EST_THash<int, int>::EST_THash(int, unsigned int (*)(int const&, unsigned int))'
wfst_ops.cc:(.text+0x1206): undefined reference to `EST_THash<int, int>::val(int const&, int&) const'
wfst_ops.cc:(.text+0x122f): undefined reference to `EST_THash<int, int>::add_item(int const&, int const&, int)'
wfst_ops.cc:(.text+0x1568): undefined reference to `EST_THash<int, int>::~EST_THash()'
wfst_ops.cc:(.text+0x17d8): undefined reference to `EST_THash<int, int>::~EST_THash()'
$USER/Downloads/festival/speech_tools/lib/libestools.a(editline.o): In function `readline':
editline.c:(.text+0x7d2a): undefined reference to `tgetent'
editline.c:(.text+0x7d85): undefined reference to `tgetstr'
editline.c:(.text+0x7d9d): undefined reference to `tgetstr'
editline.c:(.text+0x7db5): undefined reference to `tgetstr'
editline.c:(.text+0x7dcd): undefined reference to `tgetstr'
editline.c:(.text+0x7e65): undefined reference to `tgetstr'
editline.c:(.text+0x7e87): undefined reference to `tgetnum'
editline.c:(.text+0x7e99): undefined reference to `tgetnum'
editline.c:(.text+0x7f21): undefined reference to `tgetstr'
collect2: error: ld returned 1 exit status

根据http://festvox.org/docs/manual-2.4.0/festival_28.html#C_002fC_002b_002b-API,我将festival / src / include和speech_tools / include添加到搜索路径,除了与festival / src / lib / libFestival.a,speech_tools / lib / libestools.a链接, speech_tools / lib / libestbase.a和speech_tools / lib / libeststring.a。

我正在尝试使用g ++和festival 2.4.0在Arch Linux上构建它。

编辑: 使用的构建命令是

g++ -o bin/Debug/festival_test obj/Debug/main.o /usr/lib/libcurl.so /home/joshua/Downloads/festival/festival/src/lib/libFestival.a /home/joshua/Downloads/festival/speech_tools/lib/libestbase.a /home/joshua/Downloads/festival/speech_tools/lib/libestools.a /home/joshua/Downloads/festival/speech_tools/lib/libeststring.a

我正在使用CodeBlocks,因此这是默认的构建命令

编辑2: 在构造命令中添加-lncurses消除了与readline相关的未定义引用错误,但其他错误仍然存​​在

/home/joshua/Downloads/festival/speech_tools/lib/libestools.a(EST_PST.o): In function `EST_PredictionSuffixTree::test(EST_String)':
EST_PST.cc:(.text+0x2d30): undefined reference to `confusion(EST_TKVL<EST_String, EST_String>&, EST_TList<EST_String>&)'
EST_PST.cc:(.text+0x2d40): undefined reference to `print_confusion(EST_FMatrix const&, EST_TKVL<EST_String, EST_String>&, EST_TList<EST_String>&)'
/home/joshua/Downloads/festival/speech_tools/lib/libestools.a(wfst_ops.o): In function `EST_WFST::determinize(EST_WFST const&)':
wfst_ops.cc:(.text+0x1136): undefined reference to `EST_THash<int, int>::EST_THash(int, unsigned int (*)(int const&, unsigned int))'
wfst_ops.cc:(.text+0x1206): undefined reference to `EST_THash<int, int>::val(int const&, int&) const'
wfst_ops.cc:(.text+0x122f): undefined reference to `EST_THash<int, int>::add_item(int const&, int const&, int)'
wfst_ops.cc:(.text+0x1568): undefined reference to `EST_THash<int, int>::~EST_THash()'
wfst_ops.cc:(.text+0x17d8): undefined reference to `EST_THash<int, int>::~EST_THash()' 

编辑3: 将libestbase设置为链接最后修复了错误。

1 个答案:

答案 0 :(得分:0)

它可能与此错误报告有关: https://bugzilla.redhat.com/show_bug.cgi?id=499837

它建议您在 ncurses 库中明确链接其他库似乎包含的readline库。所以你要添加:

-lncurses

到你的命令。