-1

im trying to get started using pocketsphinx but I get this error:

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

every time I run this code:

#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;
}
Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
N. Chalifour
  • 103
  • 10
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – too honest for this site Jul 25 '16 at 22:24
  • I have read the page and it seems to be the same deal but I don't understand how to fix it in my situation. can you plz help? @Olaf – N. Chalifour Jul 25 '16 at 22:44

1 Answers1

1

You should also link to the pocketsphinx library:

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

I guessed the location of libpocketphinx.so, libsphinxbase.so and libsphinxad.so using the prefix you provided for the includes.

Ishay Peled
  • 2,783
  • 1
  • 23
  • 37