我正在尝试使用 MSVC 编译带有 Flite 文本到语音库的 C 程序,但我遇到了未解决的外部符号错误。
我从 Flite 文档中的“C 示例”开始,但他们使用 gcc。我能够通过链接 ws2_32.lib 和 legacy_stdio_definitions.lib 来消除一些错误,但我找不到其余错误的解决方案。
我只需要使用不同的编译器,还是有一些解决方案可以让我使用 MSVC?
主程序
#include "flite.h"
register_cmu_us_kal();
int main(int argc, char **argv)
{
cst_voice *v;
if (argc != 2)
{
fprintf(stderr, "usage: flite_test FILE\n");
exit(-1);
}
flite_init();
v = register_cmu_us_kal(NULL);
flite_file_to_speech(argv[1], v, "play");
}
构建.bat
cl ..\src\main.c -I "../lib/Flite/include/" /link ws2_32.lib legacy_stdio_definitions.lib /LIBPATH:"../lib/Flite/lib" libflite_cmu_us_kal.a libflite_usenglish.a libflite_cmulex.a libflite.a
结果
build.bat
Microsoft (R) C/C++ Optimizing Compiler Version 19.13.26128 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
main.c
..\src\main.c(17): warning C4047: '=': 'cst_voice *' differs in levels of indirection from 'int'
Microsoft (R) Incremental Linker Version 14.13.26128.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
ws2_32.lib
legacy_stdio_definitions.lib
/LIBPATH:../lib/Flite/lib
libflite_cmu_us_kal.a
libflite_usenglish.a
libflite_cmulex.a
libflite.a
main.obj
libflite_usenglish.a(us_expand.o) : error LNK2019: unresolved external symbol __locale_ctype_ptr referenced in function en_exp_letters
libflite.a(cst_string.o) : error LNK2001: unresolved external symbol __locale_ctype_ptr
libflite.a(regexp.o) : error LNK2001: unresolved external symbol __locale_ctype_ptr
libflite.a(cst_lexicon.o) : error LNK2019: unresolved external symbol __getreent referenced in function cst_lex_make_entry
libflite.a(cst_error.o) : error LNK2001: unresolved external symbol __getreent
libflite.a(cst_tokenstream.o) : error LNK2001: unresolved external symbol __getreent
libflite.a(cst_mmap_posix.o) : error LNK2019: unresolved external symbol getpagesize referenced in function cst_mmap_file
libflite.a(cst_mmap_posix.o) : error LNK2019: unresolved external symbol mmap referenced in function cst_mmap_file
libflite.a(cst_mmap_posix.o) : error LNK2019: unresolved external symbol munmap referenced in function cst_munmap_file
libflite.a(au_oss.o) : error LNK2019: unresolved external symbol ioctl referenced in function audio_open_oss
main.exe : fatal error LNK1120: 6 unresolved externals