0

スペルチェック プログラムと libspellcheck ライブラリのコンパイルに成功しました。今、私の問題は、他の開発者が私の libspellcheck を使用できるようにすることです。簡単なテスト プログラムを作成しました。

#include <spellcheck.h>
#include <iostream>

using namespace std;

int main(void)
{

    bool spell_result = check_spelling("english.dict", "abed");

    if(spell_result == true)
    {
        cout << "your dictionary / libspellcheck works!" << endl;
    }
    else
    {
        cout << "problem with your dictionary / libspellcheck" << endl;
    }

    return 0;
}

すべてが正常に機能している場合、プログラムは次のように出力します。

あなたの辞書 / libspellcheck は動作します

ただし、このプログラムはコンパイルさえしません。私が使用した:

g++ -lspellcheck -o テスト test.cpp

そして、それはうまくいきませんでした。コンパイラが私にこれを与えるので、これはヘッダーファイルの問題だと思います:

test.cpp: In function ‘int main()’:
test.cpp:9:59: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
test.cpp:9:59: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
/tmp/ccIz3ivT.o: In function `main':
test.cpp:(.text+0x19): undefined reference to `check_spelling(char*, char*)'
collect2: ld returned 1 exit status

唯一の問題は、spellcheck.h が /usr/include にあることです。これは、あるべきだと私が信じている場所です。私の質問は、このエラーをどのように修正すればよいかということです。これはヘッダー ファイルの問題でしたか、それとも libspellcheck の問題でしたか。追加のコードを確認する必要がある場合は、喜んで提供します。spellcheck と libspellcheck は GPL の下でライセンスされています。

4

1 に答える 1

2

check_spellingヘッダーの宣言が正しいと仮定して、これを試してください:

g++ -o test test.cpp -lspellcheck

(コマンドラインのライブラリによっては、オブジェクトの-lにある必要があります)。ヘッダーの時点で、実際に見つかって使用されているか、リンカーではなくコンパイラからエラーが発生します。

于 2013-01-21T17:24:02.983 に答える