2

我不能静态链接库中的hunspell我的C++项目在Visual Studio 2010中问题在Visual Studio静态链接库中的hunspell 2010

我下载的hunspell,去hunspell-1.3.1\src\win_api文件夹。我在Visual Studio 2010中打开libhunspell.vcproj文件并转换项目。我在Realease配置中构建解决方案,并在hunspell-1.3.1\src\win_api\Release\libhunspell文件夹中生成“libhunspel.lib”文件。

在我简单的C++控制台程序使用hunpell:

  • 我加入libhunspel.lib文件这个文件夹中属性页/配置属性/ VC++目录/库目录

  • 我添加“hunspell-1.3.1 \ src \”文件夹到属性页/配置属性/ VC++目录/包含目录

  • 和“libhunspell.lib”至属性页/链接器/输入/附加依赖

但它仍然给我解析的外部符号错误:

Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall Hunspell::spell(char const *,int *,char * *)" ([email protected]@@[email protected]) 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 *)" ([email protected]@[email protected]@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)" ([email protected]@[email protected]) 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将被加载。

回答

1

你需要把“#define HUNSPELL_STATIC”放在stdafx.h的某处。