使用Hunspell的简单C ++控制台应用程序

时间:2013-05-07 23:21:26

标签: c++ hunspell

我搜索过并发现了很多关于使用Hunspell的文章,但到目前为止,他们都没有真正帮助过我。 C++ - Using HunSpell 1.3.2 with Visual Studio 2010似乎正是我想要做的,但在跟着问题,回答和链接材料后,我仍然遇到问题。

基本上,我对C ++很陌生,并且正在努力学习如何将Hunspell合并到我正在开发的应用程序中。由于这对我来说是新的,我试图从创建一个简单的控制台应用程序开始,然后从那里开始。

这是我到目前为止所做的事情(再次,我已经按照链接问题中列出的所有步骤进行了操作)

#include "stdafx.h"
#include <iostream>
#include <string>

#include <hunspelldll.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
Hunspell *spellObj = (Hunspell *)hunspell_initialize("HunSpell-dic\\en_us.aff",
    "HunSpell-dic\\en_us.dic");

char str[60];
cin >> str;

int result = hunspell_spell(spellObj, str);

if (result==0)
    cout << "Spelling Error!";
else
    cout << "Correct Spelling!";

hunspell_uninitialize(spellObj);
return 0;
}

我已经添加了配置属性和链接器的路径,但是当我构建时,我收到以下错误:

Error   1   error LNK2019: unresolved external symbol __imp__hunspell_uninitialize referenced in function _wmain    C:\Users\owner\Documents\My Code Vault\Sandbox\2010Sandbox\Console_Spellcheck\Console_Spellcheck.obj    Console_Spellcheck
Error   2   error LNK2019: unresolved external symbol __imp__hunspell_spell referenced in function _wmain   C:\Users\owner\Documents\My Code Vault\Sandbox\2010Sandbox\Console_Spellcheck\Console_Spellcheck.obj    Console_Spellcheck
Error   3   error LNK2019: unresolved external symbol __imp__hunspell_initialize referenced in function _wmain  C:\Users\owner\Documents\My Code Vault\Sandbox\2010Sandbox\Console_Spellcheck\Console_Spellcheck.obj    Console_Spellcheck
Error   4   error LNK1120: 3 unresolved externals   C:\Users\owner\Documents\My Code Vault\Sandbox\2010Sandbox\Debug\Console_Spellcheck.exe Console_Spellcheck

我确信这只是一件简单的事情,我已经错过了这个新手,但是我已经把头发拉了几个小时,到目前为止没有运气。任何建议都会得到肆无忌惮的感激: - )

2 个答案:

答案 0 :(得分:0)

您需要将.lib文件指定为附加链接器输入依赖项

答案 1 :(得分:0)

看起来我能找到答案。阅读:Problem with statically linking hunspell library in visual studio 2010之后,我在stdafx.h文件中尝试了#define HUNPSPELL_STATIC,这解决了我遇到的错误。

相关问题