我试图开始使用Pocketsphinx,但出现此错误:

gcc -I /home/noahchalifour/libraries/pocketsphinx/include -I /home/noahchalifour/libraries/sphinxbase/include pocketsphinx.c -o pocketsphinx
/tmp/ccagvqgz.o: In function `main':
pocketsphinx.c:(.text+0x20): undefined reference to `ps_args'
pocketsphinx.c:(.text+0x6b): undefined reference to `cmd_ln_init'
collect2: error: ld returned 1 exit status


每次我运行这段代码:

#include <pocketsphinx.h>

#define MODELDIR "/home/libraries/pocketsphinx/model"

int main(int argc, char *argv[])
{
    ps_decoder_t *ps = NULL;
    cmd_ln_t *config = NULL;

    config = cmd_ln_init(NULL, ps_args(), TRUE,
             "-hmm", MODELDIR "/en-us/en-us",
             "-lm", MODELDIR "/en-us/en-us.lm.bin",
             "-dict", MODELDIR "/en-us/cmudict-en-us.dict",
             NULL);

    printf("Success!\n");

    return 0;
}

最佳答案

您还应该链接到pocketsphinx库:

gcc -I /home/noahchalifour/libraries/pocketsphinx/include \
    -I /home/noahchalifour/libraries/sphinxbase/include \
    -L /home/noahchalifour/libraries/pocketsphinx/lib \
    -L /home/noahchalifour/libraries/sphinxbase/lib \
    -lpocketsphinx -lsphinxbase -lsphinxad
    pocketsphinx.c -o pocketsphinx


我使用您为包含项提供的前缀猜测了libpocketphinx.solibsphinxbase.solibsphinxad.so的位置。

关于c - 尚未解决的符号构建Pocketsphinx应用程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38577635/

10-13 08:25