質問

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 :-)

役に立ちましたか?

解決 2

Looks like I was able to find the answer. After reading: Problem with statically linking hunspell library in visual studio 2010, I tried #define HUNPSPELL_STATIC in my stdafx.h file, and that resolved the error I was encountering.

他のヒント

You need to specify the .lib file as an additional linker input dependency

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top