我无法在 Visual Studio 2010 中将 hunspell 库静态链接到我的 C++ 项目。
我下载了hunspell并转到hunspell-1.3.1\src\win_api
文件夹。我在 Visual Studio 2010 中打开了 libhunspell.vcproj 文件并转换了项目。我在Realease
配置中构建了解决方案,它在文件夹中生成了“libhunspel.lib”文件hunspell-1.3.1\src\win_api\Release\libhunspell
。
在我使用 hunpell 的简单 C++ 控制台程序中:
我在属性页/配置属性/VC++ 目录/库目录中添加了这个带有 libhunspel.lib 文件的文件夹
我将“hunspell-1.3.1\src\”文件夹添加到属性页/配置属性/VC++ 目录/包含目录
和“libhunspell.lib”到Property Pages/Linker/Input/Additional Dependancies。
但它仍然给我未解决的外部符号错误:
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall Hunspell::spell(char const *,int *,char * *)" (__imp_?spell@Hunspell@@QAEHPBDPAHPAPAD@Z) referenced in function _main C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj hunspell_learning
Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Hunspell::Hunspell(char const *,char const *,char const *)" (__imp_??0Hunspell@@QAE@PBD00@Z) referenced in function _main C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj hunspell_learning
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Hunspell::~Hunspell(void)" (__imp_??1Hunspell@@QAE@XZ) referenced in function _main C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj hunspell_learning
Error 4 error LNK1120: 3 unresolved externals C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\Debug\hunspell_learning.exe 1 1 hunspell_learning
我不知道有什么问题。我也尝试使用动态库。Release_dll
在配置中构建 Hunspell 解决方案,并将我的应用程序中的包含目录hunspell-1.3.1\src\win_api\Release_dll\libhunspell
更改为并编译。我只需要复制我的可执行程序所在的 libhunspell.dll,以便加载 dll。