Menu

Compiling sphinxbase, pocketsphinx Static Lib

Help
clint
2011-11-16
2012-09-22
  • clint

    clint - 2011-11-16

    Hello,

    First off, I'm using Windows 7 64bit, Microsoft Visual Studio 2010 and
    sphinxbase / pocketsphinx 0.7

    I'm trying to develop an application that needs speech recognition. I want to
    wrap up specific functionality into a dll (for example, sphinxwrapper.dll),
    and make that available to my application. But one of my deployment restraints
    is that I need just one dll for all the speech recognition (as opposed to
    sphinxbase.dll, pocketshinx.dll and sphinxwrapper.dll).

    My understanding is that I can do this by compiling sphinxbase and
    pocketsphinx as Static Libraries (.lib) when I use them to compile
    sphinxwrapper.dll; however, I haven't been able to get that far. I can compile
    sphinxbase.lib, but I can't get anything to compile after that.

    Here are the steps I've taken:

    1. Downloaded, unzipped and renamed sphinxbase and pocketsphinx 0.7
    2. Compiled all just fine
    3. Tried to run pocketsphinx_continuous.exe. It failed (as expected) because I didn't have sphinxbase.dll in the directory. This is the kind of thing I'm expecting to fix by compiling sphinxbase as a .lib file.

    4. Compiled sphinxbase.lib

    5. to do this I changed sphinxbase Project -> General -> Configuration Type from Dynamic Library (.dll) to Static Library (.lib)
    6. Compiled just fine

    7. Tried to unsuccessfully to compile other sphinxbase projects
      For this step, all the examples will be based on compiling
      sphinx_lm_convert.exe, but they all have similar linking errors.

    With the default settings I get


    *1>------ Build started: Project: sphinxbase, Configuration: Release
    Win32 ------
    1> sphinxbase.vcxproj ->
    C:\sphinx\sphinxbase\win32\sphinxbase../../bin/Release\sphinxbase.lib
    2>------ Build started: Project: sphinx_lm_convert, Configuration: Release
    Win32 ------
    2> sphinx_lm_convert.c
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__ngram_type_to_str
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__logmath_init
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__ngram_str_to_type
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __impE_die_error
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    imp__ngram_model_read
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __impE_pr_warn
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    imp__ngram_model_recode
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __impE_pr_info
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    imp__ngram_model_write
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__cmd_ln_str_r
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__cmd_ln_int_r
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__ngram_model_free
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__ngram_model_casefold
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__err_set_debug_level
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __impE_pr_info_header
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    imp__cmd_ln_float_r
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__ngram_file_name_to_type
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __imp__cmd_ln_parse_r
    2>sphinx_lm_convert.obj : error LNK2001: unresolved external symbol
    __impEprheader
    2>C:\sphinx\sphinxbase\bin\Release\sphinx_lm_convert.exe : fatal error
    LNK1120: 19 unresolved externals
    ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped
    ==========
    *


    I also tried changing some of the project settings that I normally set when
    linking a static library:
    sphinx_lm_convery project properties -> Configuration Properties
    ** C/C++ -> General -> Additional Include Directories added ../../include/sphinxbase just in case, as the header files seems to have been moved from \include to \include\sphinxbase between 0.6.1 and 0.7
    ** Linker -> General -> Additional Library Directories ** added ../../bin/$(Configuration)
    * ** Linker -> Input -> Additional Dependencies ** added sphinxbase.lib

    But I got the same output when trying to compile it again.

    Any thoughts on where I might be going wrong, or suggestions on what to try
    next?

    Thanks!**

     
  • Nickolay V. Shmyrev

    If you want to compile everything statically, you need to redefine the macros
    SPHINXBASE_EXPORT and POCKETSPHINX_EXPORT. By default they are defined in
    header files as __declspec(dllexport). Header file is sphinxbase_export.h and
    pocketsphinx_export.h.

     

Log in to post a comment.