Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] How to use Hunspell in Qt on Windows system
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
12 Posts 2 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    floreal797
    wrote on last edited by
    #1

    Hi,

    In my application, I try to use a spell checker. I have found this :
    http://qt-project.org/wiki/Spell-Checking-with-Hunspell

    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 : http://sourceforge.net/projects/ezwinports/files/

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

    Thank you in advance for your help,

    Floréal.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        floreal797
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • F Offline
            F Offline
            floreal797
            wrote on last edited by
            #5

            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:
            https://github.com/zdenop/hunspell-mingw
            (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.

            Floréal.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Are you sure that both parameters contains valid paths ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • F Offline
                F Offline
                floreal797
                wrote on last edited by
                #7

                For the INCLUDEPATH yes, it is like author say (http://qt-project.org/wiki/Spell-Checking-with-Hunspell).

                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?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

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

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    floreal797
                    wrote on last edited by
                    #9

                    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...

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      floreal797
                      wrote on last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

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

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          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

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved