Add lib
-
What folder should I put hunspell (Windows)?
@LIBS += -lhunspell@
I tried adding the main folder of the project, tried to add the folder "src", but both cause the following error:
bq. error: cannot find -lhunspell
I tried doing this:
@LIBS += -LC:/Users/cr/Desktop/QT/qtwebkit-plugins-master/src/hunspell@
but this error occurs:
bq. C:\Users\cr\Desktop\QT\qtwebkit-plugins-master\src\spellcheck\speller.cpp:57: error: undefined reference to Hunspell::Hunspell(char const*, char const*, char const*)
see all errors that occur in the following image:
!http://s7.postimg.org/jvt5emw7v/5ae81318_090d_11e3_8dee_23f730f163bb.png(error lib)! -
Possibly that library was compiled using a different compiler than the one you are using.
-
I'm using mingw 4.8.
-
I don't care about that much, but thanks for sharing. Let's try again:
have hunspell, your application and Qt libraries all been compiled using the same compiler?Also, remember to show the compiler the headers using INCLUDEPATH in your .pro file. I guess you have done that already, though, as compiler seems happy.
-
Thanks, I'm almost there, but still some errors occur, see:
Code:
@ HEADERS = $$PWD/hunspell/affentry.hxx
$$PWD/hunspell/affixmgr.hxx
$$PWD/hunspell/atypes.hxx
$$PWD/hunspell/baseaffix.hxx
$$PWD/hunspell/csutil.hxx
$$PWD/hunspell/dictmgr.hxx
$$PWD/hunspell/filemgr.hxx
$$PWD/hunspell/hashmgr.hxx
$$PWD/hunspell/htypes.hxx
$$PWD/hunspell/hunspell.h
$$PWD/hunspell/hunspell.hxx
$$PWD/hunspell/hunzip.hxx
$$PWD/hunspell/langnum.hxx
$$PWD/hunspell/phonet.hxx
$$PWD/hunspell/suggestmgr.hxx
$$PWD/hunspell/w_char.hxx
$$PWD/qwebkitplatformplugin.h
$$PWD/spellcheck.h
$$PWD/speller.hSOURCES += $$PWD/hunspell/affentry.cxx \ $$PWD/hunspell/affixmgr.cxx \ $$PWD/hunspell/csutil.cxx \ $$PWD/hunspell/dictmgr.cxx \ $$PWD/hunspell/filemgr.cxx \ $$PWD/hunspell/hashmgr.cxx \ $$PWD/hunspell/hunspell.cxx \ $$PWD/hunspell/hunzip.cxx \ $$PWD/hunspell/phonet.cxx \ $$PWD/hunspell/suggestmgr.cxx \ $$PWD/hunspell/utf_info.cxx \ $$PWD/spellcheck.cpp \ $$PWD/speller.cpp@
Errors:
@./....\qtwebkit-plugins-master\build\affixmgr.o: In functionZN8AffixMgrD2Ev': C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/affixmgr.cxx:187: undefined reference to
RepList::~RepList()'
C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/affixmgr.cxx:188: undefined reference toRepList::~RepList()' ./..\..\qtwebkit-plugins-master\build\affixmgr.o: In function
ZN8AffixMgr15parse_convtableEPcP7FileMgrPP7RepListPKc':
Makefile.Debug:102: recipe for target '....\qtwebkit-plugins-master\bin\qtwebkitpluginsd.dll' failed
C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/affixmgr.cxx:3624: undefined reference toRepList::RepList(int)' C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/affixmgr.cxx:3656: undefined reference to
RepList::~RepList()'
C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/affixmgr.cxx:3681: undefined reference toRepList::add(char*, char*)' ./..\..\qtwebkit-plugins-master\build\hunspell.o: In function
ZN8Hunspell5spellEPKcPiPPc':
C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/hunspell.cxx:346: undefined reference toRepList::conv(char const*, char*)' ./..\..\qtwebkit-plugins-master\build\hunspell.o: In function
ZN8Hunspell7suggestEPPPcPKc':
C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/hunspell.cxx:700: undefined reference toRepList::conv(char const*, char*)' C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/hunspell.cxx:1009: undefined reference to
RepList::conv(char const*, char*)'
./....\qtwebkit-plugins-master\build\hunspell.o: In functionZN8Hunspell7analyzeEPPPcPKc': C:\Users\cr\Desktop\DESK\CPP\QT\build-qtwebkit-plugins-Desktop_Qt_5_1_0_MinGW_32bit-Debug\src/../../qtwebkit-plugins-master/src/spellcheck/hunspell/hunspell.cxx:1384: undefined reference to
RepList::conv(char const*, char*)'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [....\qtwebkit-plugins-master\bin\qtwebkitpluginsd.dll] Error 1@I did download these files:
QtWekibt-plugins:
https://github.com/QupZilla/qtwebkit-plugins/
hunspell:
http://downloads.sourceforge.net/hunspell/hunspell-1.3.2.tar.gz
-
So now you are not linking the library, but compiling it into (inside) your application.
-
I have to compile the ./configure file (which is in the folder hunspell) before adding to the QT project. Is this the problem?
-
So much to explain... ok let's do it from grounds up.
There are many ways in which you can include external code/ functionality. One of them is to include a (shared) library. Library is a binary file that - given certain knowledge - can be used by other compiled binaries. It is not possible out of the box - in order to access the library, you need a list of all the exported (that is: available to you) methods and classes. This (I'm simplifying a lot here) is done by including the library headers into your code. When those headers are read by the compiler/ linker, they adjust your code so that it can talk with that binary library after compilation. In Qt/qmake, this is done by adding header directories only to INCLUDEPATH variable:
@
INCLUDEPATH += /path/to/library/headers
@So, you need to compile (or download precompiled) library first, then compile your project while pointing it to those header files. To stress the point: library sources (.cpp) are not present anywhere in this scenario, they are not needed :)
Another way is to use static libraries. This is very similar to above in practice, although it differs in theory. I won't get into that, we don't need to know this at this moment.
Yet another way, possible but seldom used, is to incorporate all the headers and sources into your project (your last attempt does this) using HEADERS and SOURCES variables in qmake. This does not require you to precompile your library, but is usually much harder to do, can cause licensing problems and in general means more work for little gain. Once compiled, the library is not really a library anymore: it is just another part of your application, fully integrated.
Hope this clears things up a bit.