Important: Please read the Qt Code of Conduct -

[SOLVED] How to use Hunspell in Qt on Windows system

  • Hi,

    In my application, I try to use a spell checker. I have found this :

    It works with hunspell and give a very well spell checking. It works perfectly on Linux, but when I tested it in Windows and it doesn't works... I have this error messages:
    @spellchecker.obj : error LNK2019: unresolved external symbol "public: __thiscall Hunspell::Hunspell(char const *,char const *,char const *)" (??0Hunspell@@QAE@PBD00@Z) referenced in function "public: __thiscall SpellChecker::SpellChecker(class QString const &,class QString const &)" (??0SpellChecker@@QAE@ABVQString@@0@Z)
    spellchecker.obj : error LNK2019: unresolved external symbol "public: __thiscall Hunspell::~Hunspell(void)" (??1Hunspell@@QAE@XZ) referenced in function "public: void * __thiscall Hunspell::`scalar deleting destructor'(unsigned int)" (??_GHunspell@@QAEPAXI@Z)
    spellchecker.obj : error LNK2019: unresolved external symbol "public: int __thiscall Hunspell::spell(char const *,int *,char * *)" (?spell@Hunspell@@QAEHPBDPAHPAPAD@Z) referenced in function "public: bool __thiscall SpellChecker::spell(class QString const &)" (?spell@SpellChecker@@QAE_NABVQString@@@Z)
    spellchecker.obj : error LNK2019: unresolved external symbol "public: int __thiscall Hunspell::suggest(char * * *,char const *)" (?suggest@Hunspell@@QAEHPAPAPADPBD@Z) referenced in function "public: class QStringList __thiscall SpellChecker::suggest(class QString const &)" (?suggest@SpellChecker@@QAE?AVQStringList@@ABVQString@@@Z)
    spellchecker.obj : error LNK2019: unresolved external symbol "public: int __thiscall Hunspell::add(char const *)" (?add@Hunspell@@QAEHPBD@Z) referenced in function "private: void __thiscall SpellChecker::put_word(class QString const &)" (?put_word@SpellChecker@@AAEXABVQString@@@Z)
    debug\CeCWriter.exe : fatal error LNK1120: 5 unresolved externals@

    I have adapt my project file as indicated in the page, like this:
    @unix {
    INCLUDEPATH += /usr/include/hunspell
    contains(QMAKE_HOST.arch, x86_64) {
    LIBS += /usr/lib/x86_64-linux-gnu/libhunspell-1.3.a
    else {
    LIBS += /usr/lib/i386-linux-gnu/libhunspell-1.3.a

    win32 {
    INCLUDEPATH +=C:\hunspell\include
    LIBS += C:\hunspell\lib\libhunspell-1.3.a

    I precise I have installed hunspell from the installer I have found here :

    Why it doesn't works and how solve my problem?

    Thank you in advance for your help,


  • Lifetime Qt Champion


    First thing to do: change the backslashes, either escape them or use the unix notation since Qt supports that on Windows.

    By the way, what compiler are you using ?

  • Hi,

    I used slashes instead of backslashes first and I had the same errors.

    I am using microsoft visual studio c++ 11.0 (2012), as it is the default complator that Qt propose me.

  • Lifetime Qt Champion

    Looks like you are trying to link a MinGW library to your MSVC build, aren't you ?

  • Ok,

    I have tried using MinGW to compile my project. First, it does not work with the hunspell I have.

    I search and I found a mingw version of hunspell, here:
    (I use the zip compiled in Windows XP that they give).

    I try with it.

    My .pro file contains now:
    @win32 {
    INCLUDEPATH += C:/hunspell/include
    LIBS += C:/hunspell/lib/libhunspell.a

    My program start now successfully... but when I push the button to begin spell checking the program crash. With debug, I found it crash on that line, in spellchecker.cpp:
    @ _hunspell = new Hunspell(affixFilePathBA.constData(), dictFilePathBA.constData());@

    Do you know why and how solve the problem?

    Thank you for your help, and in advance for your future help. It's really important for me to find a solution.


  • Lifetime Qt Champion

    Are you sure that both parameters contains valid paths ?

  • For the INCLUDEPATH yes, it is like author say (

    For the LIBS, it is written a file to a .lib file but I don't find any .lib file. I think .lib file is for visual studio project as compilation of hunspell with visual studio generate a .lib file.

    For linux, we have to use a .a file, so as it was a .a file in the lib directory of hunspell I use it.

    Do you think the errors are in these paths?

  • Lifetime Qt Champion

    Sorry, I meant the parameters you are passing to the Hunspell constructor

  • I think yes.

    files are in C:\hunspell\dics\ and are named fr.dic and fr.aff.

    So I use C:/hunspell/dics/fr as the base name and I have checked the program suffix files with .dic and .aff before calling Hunspell constructor.

    This part work very well on linux (with its own path, of course), with exactly the same code. I don't know why it crash only on windows...

  • I have also tried to copy dic files from linux to windows to use exactly the sames, but it does not solve the problem

  • Lifetime Qt Champion

    Does the debugger give you more information about where exactly it crashes in Hunspell's library ?

  • Lifetime Qt Champion

    Indeed, especially on Windows, you have to ensure you use the same compiler for all libraries e.g. MSVC's compilers are not compatible between versions. MinGW should be more flexible but is also known to break compatibility from time to time

Log in to reply