Skip to content

macOS compilation error: lexicon.c:202:12: error: implicit declaration of function 'str2words' is invalid in C99 #27

@lsonnino

Description

@lsonnino

I am unable to compile the code on macOS 12.1 Monterey. After running ./configure, the make commands fails:

Making all in libcommon
/bin/sh ../../../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../../include   -I/Users/lorenzo/Downloads/sphinx_install/sphinxtrain/../sphinxbase/include -I/Users/lorenzo/Downloads/sphinx_install/sphinxtrain/../sphinxbase/include  -I../../../include -g -O2 -fPIC -DPIC -MT lexicon.lo -MD -MP -MF .deps/lexicon.Tpo -c -o lexicon.lo lexicon.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../include -I/Users/lorenzo/Downloads/sphinx_install/sphinxtrain/../sphinxbase/include -I/Users/lorenzo/Downloads/sphinx_install/sphinxtrain/../sphinxbase/include -I../../../include -g -O2 -fPIC -DPIC -MT lexicon.lo -MD -MP -MF .deps/lexicon.Tpo -c lexicon.c  -fno-common -DPIC -o .libs/lexicon.o
lexicon.c:202:12: error: implicit declaration of function 'str2words' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        n_phone = str2words(line->buf, NULL, 0) - 1;
                  ^
1 error generated.
make[3]: *** [lexicon.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

I have both Perl v5.30.3 (which is installed by default on macOS) and Python 3.9.7 installed. I also installed the latest version (5-prealpha) of sphinxbase and pocketsphinx through code compilation (sudo make install) and I have the compiled source code of both in folders named sphinxbase and pocketsphinx respectively in the same parent folder as my sphinxtrain folder I am trying to compile. (The absolute path to those folders does not contain any spaces, as this seem to be an issue as well.)

Finally, adding #include <sphinxbase/strfuncs.h> to src/libs/libcommon/lexicon.c and src/libs/libcommon/mk_phone_seq.c seems to solve the problem, however another error occurs:

Making all in libio
/bin/sh ../../../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../../include   -I/Users/lorenzo/Downloads/sphinx_install/sphinxtrain/../sphinxbase/include -I/Users/lorenzo/Downloads/sphinx_install/sphinxtrain/../sphinxbase/include  -I../../../include -g -O2 -fPIC -DPIC -MT corpus.lo -MD -MP -MF .deps/corpus.Tpo -c -o corpus.lo corpus.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../include -I/Users/lorenzo/Downloads/sphinx_install/sphinxtrain/../sphinxbase/include -I/Users/lorenzo/Downloads/sphinx_install/sphinxtrain/../sphinxbase/include -I../../../include -g -O2 -fPIC -DPIC -MT corpus.lo -MD -MP -MF .deps/corpus.Tpo -c corpus.c  -fno-common -DPIC -o .libs/corpus.o
corpus.c:1314:12: error: implicit declaration of function 'areadfloat' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            ret = areadfloat(mk_filename(DATA_TYPE_MFCC, cur_ctl_path),
                  ^
corpus.c:1318:12: error: implicit declaration of function 'areadfloat_part' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            ret = areadfloat_part(mk_filename(DATA_TYPE_MFCC, cur_ctl_path),
                  ^
corpus.c:1388:9: error: implicit declaration of function 'areadshort' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (areadshort(mk_filename(DATA_TYPE_SEG, rel_path), (int16**)seg, n_seg) < 0)
        ^
3 errors generated.
make[3]: *** [corpus.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

I suppose adding another include would solve this problem as well but I guess this is not the way to do it. Am I missing something ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions