2016-06-23 63 views
0

我已經設置了額外的庫目錄和lib文件夾以用於visual studio。還建立成功,但每當我試圖從Visual Studio執行程序返回以下錯誤:無法啓動程序。 Pocketsphinx.dll缺少錯誤

The program can't start because pocketsphinx.dll is missing from your computer. Try reinstalling the program to fix problem.

當我檢查的目錄,我看到pocketsphinx.dll在那裏。

我的代碼(從pocketsphinx維基截取):

#include <pocketsphinx.h> 

#define MODELDIR "C:\Sphinx\pocketsphinx\model" 
int 
main(int argc, char *argv[]) 
{ 
ps_decoder_t *ps; 
cmd_ln_t *config; 
FILE *fh; 
char const *hyp, *uttid; 
int16 buf[512]; 
int rv; 
int32 score; 

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); 
if (config == NULL) { 
    fprintf(stderr, "Failed to create config object, see log for details\n"); 
    return -1; 
} 

ps = ps_init(config); 
if (ps == NULL) { 
    fprintf(stderr, "Failed to create recognizer, see log for details\n"); 
    return -1; 
} 

fh = fopen("goforward.raw", "rb"); 
if (fh == NULL) { 
    fprintf(stderr, "Unable to open input file goforward.raw\n"); 
    return -1; 
} 

rv = ps_start_utt(ps); 

while (!feof(fh)) { 
    size_t nsamp; 
    nsamp = fread(buf, 2, 512, fh); 
    rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE); 
} 

rv = ps_end_utt(ps); 
hyp = ps_get_hyp(ps, &score); 
printf("Recognized: %s\n", hyp); 

fclose(fh); 
ps_free(ps); 
cmd_ln_free_r(config); 

return 0; 
} 

編輯:pocketsphinx.dll是在bin\Debug\x64文件夾等作爲pocketsphinx.lib

+1

「我看到pocketsphinx.dll在那裏。」那是哪裏? – tkausl

+0

我假設您的項目(您在x64 Debug配置中構建的)的可執行文件不在'bin \ Debug \ x64'中。 – drescherjm

回答

1

當您在Visual Studio中的調試器中運行程序時,默認情況下您的工作目錄參數(項目設置 - >配置屬性 - >調試)爲$(ProjectDir)。將其更改爲$(TargetDir)並且它應該開始。

相關問題