Menu

cmd_ln_t compile error

Help
Anonymous
2011-04-12
2019-05-07
  • Anonymous

    Anonymous - 2011-04-12

    include <pocketsphinx.h>

    int
    main(int argc, char argv)
    {
    ps_decoder_t
    ps;
    cmd_ln_t *config;

    config = cmd_ln_init(NULL, ps_args(), TRUE,
    "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
    "-lm", MODELDIR "/lm/en/turtle.DMP",
    "-dict", MODELDIR "/lm/en/turtle.dic",
    NULL);
    if (config == NULL)
    return 1;

    return 0;
    }
    // the code above is get from http://cmusphinx.sourceforge.net/wiki/tuturialp
    ocketsphinx

    // when i compile it,gcc gives error: expected expression before ‘/’ token
    // i right install the phinx as the instruction
    //when i run pkg-config --cflags --libs pocketsphinx sphinxbase (by the way
    it is two "-" before cflags not one as the project illustration)
    -I/usr/local/include/sphinxbase -I/usr/local/include/pocketsphinx -L/usr/local/lib -lpocketsphinx -lsphinxbase -lsphinxad
    /
    / my makefile/
    obj=hello_ps

    $(obj):$(obj).c
    gcc $(obj).c -o $(obj) -DMODELDIR="pkg-config --variable=modeldir pocketsphinx " pkg-config --cflags --libs pocketsphinx sphinxbase

    .PHONY:clean
    clean:
    rm -rf *.o $(obj)

    HELP ME !!!!!!!!!!!!!!!!!!!!!!!!!!

     
  • Nickolay V. Shmyrev

    -DMODELDIR="pkg-config --variable=modeldir pocketsphinx "

    This doesn't work in makefile the way it works in the command line. You need
    to escape the double quote otherwise it will be removed. I suggest you to try
    the following makefile:

    obj=hello_ps
    modeldir=$(shell pkg-config --variable=modeldir pocketsphinx)
    flags=$(shell pkg-config --cflags --libs pocketsphinx)
    
    $(obj):$(obj).c
            gcc $(obj).c -o $(obj) -DMODELDIR=\"$(modeldir)\" $(flags)
    
     
  • Nickolay V. Shmyrev

    I really do as your instrucion ,but the gcc still gives errors as
    below:
    hello_ps.c: In function ‘main’:
    hello_ps.c:10: error: ‘MODELDIR’ undeclared (first use in this
    function)
    hello_ps.c:10: error: (Each undeclared identifier is reported only
    once
    hello_ps.c:10: error: for each function it appears in.)
    hello_ps.c:10: error: expected ‘)’ before string constant
    make: *** Error 1
    Now i am totally confused ....Thanks a lot!

    Well, my instruction includes "Try to understand what really happens in a
    makefile". This step will be particular useful for you.

     
  • Anonymous

    Anonymous - 2011-04-14

    Thank you very much !!!
    Just as you said,i checked the makefile ,Now it is works ok!!!

     
    • Tayeb

      Tayeb - 2019-05-07

      can you show as what you did ?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.