将库添加到项目中的问题

时间:2017-05-13 11:17:49

标签: c++ ubuntu linker hunspell

我创建了一个有意使用hunspell函数的项目。我在Ubuntu工作。我安装并编译了hunspell库并将其与g ++ -o wc.exe -lhunspell-1.6 wordcheck.cxx链接,一切似乎都可以。但是当我尝试编译并启动我的项目时,我遇到了一些错误。

#include <iostream>
#include "hunspell/hunspell.hxx"

using namespace std;

int main(int argc,char** argv)
{
    FILE* lst=fopen("wordlist.txt","r");
    if(!lst)
    {
        cerr<<"Can not open file\n";
        return 1;
    }
    Hunspell* hs=new Hunspell(argv[1],argv[2]);
    delete hs;
    return 0;
}

错误是:

/home/alex2/Документы/bO/wordcheck.cxx:14:未定义引用Hunspell::Hunspell(char const*, char const*, char const*)' /home/alex2/Документы/bO/wordcheck.cxx:15: undefined reference to Hunspell ::〜Hunspell()' collect2:错误:ld返回1退出状态 的ATU

我不知道出了什么问题。我尝试使用

Hunspell* hs=new Hunspell();

并得到它的候选者需要三个参数:

/usr/local/include/hunspell/hunspell.hxx:115:3:注意:候选人:Hunspell :: Hunspell(const char *,const char *,const char *)    Hunspell(const char * affpath,const char * dpath,const char * key = NULL);

唯一的区别是char const *和const char *但我一直认为它是一回事。整个项目类似于hunspell提供的示例文件,我不知道我做错了什么以及为什么我的东西不起作用。

0 个答案:

没有答案