1

I've searched and found a bunch of articles on using Hunspell, but so far none of them have really helped me. C++ - Using HunSpell 1.3.2 with Visual Studio 2010 seems to be exactly what I'm trying to do, but after following along with the question, answer, and linked material, I'm still having problems.

Basically, I'm pretty new to C++ and am trying to learn how to incorporate Hunspell into an application I'm working on. Since this is new to me, I'm trying to start by creating a simple console app, and then going from there.

Here's what I have so far (again, I've followed all the steps outlined in the linked question)

#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;
}

I've added the paths to my configuration properties, and to the Linker, but when I build, I get the following errors:

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

I'm sure that it's just something simple I've missed being new to this, but I've been pulling my hair for a few hours on it with no luck so far. Any suggestions would be met with unbridled gratitude :-)

4

2 回答 2

0

看来我找到了答案。阅读后:在 Visual Studio 2010 中静态链接 hunspell 库的问题,我在我的 stdafx.h 文件中尝试了#define HUNPSPELL_STATIC,这解决了我遇到的错误。

于 2013-05-08T13:36:13.197 回答
0

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

于 2013-05-08T00:20:51.747 回答