C ++ - Visual Studio 2010でHunspell 1.3.2を使用する
-
13-12-2019 - |
質問
私の目標は、Hunspellを使用してHunspellを使用する単純なWin32コンソールアプリケーションを作成することです。 私はこのCodeProjectチュートリアル Visual Studio 2008とHunspell 1.2.1。
私は自分のものを書くつもりだったので、私は提供されたコードを使いたくありません。 さらに、静的ライブラリとしてではなく、DLLとしてHunspellを追加したいです。
フォロー中は、私が撮ったステップです:
- 名前MyProjectという名前のWin32コンソール(空)プロジェクトを作成しました。
- SourceForge.orgからHunspell 1.3.2をダウンロードしました。
- コピー Hunspell-1.3.2 \ SRC \ Hunspell と Win_API - myProject \ MyProject \ HunSpell-Src
- 追加されて変換されたプロジェクトlibhunspell myproject \ myproject \ funspell-src \ win-api \ libhunspell.vcproj 解決策に。
- Debug Buildを使用してdebug_dllと私のリリースビルドrelease_dllをConfiguration Managerにlibhunspellにrelease_dllを使用しました。
- libhunSpellプロジェクトの再構築、 libhunspell.dll はそれぞれdebug_dllフォルダとrelease_dllフォルダで生成されます。
- Consoleプロジェクトをlibhunspellに依存させました。 (libhunspellへの参照)
- コピー辞書ファイルen_us.aff&en_us.dicから myproject \ myproject \ funspell-dic sourceforge.orgからダウンロードした後。
CodeProjectチュートリアルに記載されているhspelledit_dllをプロセッサに追加する方法/場所を把握できません。
「コンソールアプリケーションのクラスライブラリから機能を使用する」の下に続いて、 msdn は結果を変更しませんでした。
このようなプログラムでテストしたい:
#include <iostream>
#include "HunSpell-Src/win_api/hunspelldll.h"
using namespace std;
void main()
{
void *spellObj = 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(spellObject);
}
.
VSは、コンパイルしようとすると、次のエラーメッセージが表示されます。
myproject\myproject\hunspell-src\win_api\hunspelldll.h(34): fatal error C1083: Cannot open include file: 'hunspell.hxx': No such file or directory
.
HunSpell.hxxはMyProject \ MyProject \ Hunspell-Src \ Hunspellにあります。 IntelliSenseは#include "HunSpell.hxx"をマークします。タブがメッセージ "エラー:ソースファイルHunSpell.hxx"に焦点が合わないが、それにフォーカスを与えた後、エラーが消える。
あなたの助けをありがとうございました。
解決
CodeProject Authorのカスタムコントロールを実際に使用しようとしていない限り、プリプロセッサ定義hspelledit_dllは必要ありません。それを定義したい場合(または他のプリプロセッサ定義)は、 / dを参照してください。プリプロセッサ定義)
あなたのパス文字列は、シングル\エスケープの代わりにdouble \\である必要があり、あなたはいくつかのコンパイル問題を持っています:
#include <iostream>
#include "HunSpell-Src/win_api/hunspelldll.h"
using namespace std;
void main()
{
Hunspell *spellObj = (Hunspell *)hunspell_initialize("HunSpell-Dic\\en_us.aff", "HunSpell-Dic\\en_us.dic");
// ^change * type ^cast returned void* to type that will be used later
char str[60];
cin >> str;
int result = hunspell_spell(spellObj, str);
if(result == 0)
cout << "Spelling error!";
else
cout << "Correct Spelling!";
hunspell_uninitialize(spellObj /*SpellObject is undefined*/);
// ^use correct variable
}
.
HUNSPELL.HXXの場合は、プロジェクトを見つける方法を教える必要があります。これを行うには、プロジェクト設定を開き、Configuration Properties> C ++> Generalの下にある「追加のインクルードディレクトリ」にHunSpell.hxxへのパスを開きます。 / i(追加のインクルードディレクトリ)
Projects Output Directory(。\ Debug)にmyproject\myproject\Debug_dll\libhunspell\libhunspell.dll
をコピーする必要があるか、EXEはそれを見つけることができないでしょう。