Hi,
if i try to compile the SpellChecker plugin on linux i get linker errors:
g++ -shared -L../../../devel30 ../../../.objs30/plugins/contrib/SpellChecker/DictionariesNeededDialog.o ../../../.objs30/plugins/contrib/SpellChecker/MySpellingDialog.o ../../../.objs30/plugins/contrib/SpellChecker/mythes.o ../../../.objs30/plugins/contrib/SpellChecker/OnlineSpellChecker.o ../../../.objs30/plugins/contrib/SpellChecker/SpellCheckerConfig.o ../../../.objs30/plugins/contrib/SpellChecker/SpellCheckerPlugin.o ../../../.objs30/plugins/contrib/SpellChecker/SpellCheckHelper.o ../../../.objs30/plugins/contrib/SpellChecker/SpellCheckSettingsPanel.o ../../../.objs30/plugins/contrib/SpellChecker/StatusField.o ../../../.objs30/plugins/contrib/SpellChecker/Thesaurus.o ../../../.objs30/plugins/contrib/SpellChecker/ThesaurusDialog.o ../../../.objs30/plugins/contrib/SpellChecker/wxThes.o -o ../../../devel30/share/codeblocks/plugins/libSpellChecker.so -Wl,--no-undefined -L/usr/lib/x86_64-linux-gnu -pthread -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lhunspell-1.6 -lwxSpellChecker -lcodeblocks
../../../devel30/libwxSpellChecker.a(HunspellInterface.o): In function `void wxDELETE<Hunspell>(Hunspell*&)':
/usr/include/wx-3.0/wx/defs.h:744: undefined reference to `Hunspell::~Hunspell()'
../../../devel30/libwxSpellChecker.a(HunspellInterface.o): In function `HunspellInterface::IsWordInDictionary(wxString const&)':
/home/user/codeblocks/svn/src/plugins/contrib/SpellChecker/HunspellInterface.cpp:221: undefined reference to `Hunspell::spell(char const*, int*, char**)'
../../../devel30/libwxSpellChecker.a(HunspellInterface.o): In function `HunspellInterface::GetSuggestions(wxString const&)':
/home/user/codeblocks/svn/src/plugins/contrib/SpellChecker/HunspellInterface.cpp:199: undefined reference to `Hunspell::suggest(char***, char const*)'
../../../devel30/libwxSpellChecker.a(HunspellInterface.o): In function `HunspellInterface::GetCharacterEncoding()':
/home/user/codeblocks/svn/src/plugins/contrib/SpellChecker/HunspellInterface.cpp:433: undefined reference to `Hunspell::get_dic_encoding()'
../../../devel30/libwxSpellChecker.a(HunspellInterface.o): In function `HunspellInterface::InitializeSpellCheckEngine()':
/home/user/codeblocks/svn/src/plugins/contrib/SpellChecker/HunspellInterface.cpp:69: undefined reference to `Hunspell::Hunspell(char const*, char const*, char const*)'
I have to modify the linker commands to this to be able to compile
`$(WX_CONFIG) --libs`
-lwxSpellChecker
`pkg-config hunspell --libs`
Hundspell and wxSpellChecker change place...
Not working:
-lhunspell-1.6 -lwxSpellChecker
Working
-lwxSpellChecker -lhunspell-1.6
So the order matters for gcc (as we all know...)
But for me it works fine. No idea why for you it doesn't work.
I would like to investigate about this, before i fix a problem that is not there...
As far as i understand the resolving of the symbols by the linker is revers, so if library A needs symbols from library B the library order for the linker has to be
And this is the case here: wxSpellChecker needs symbols from hunspell-1.6. Why did it ever worked? Or why did it stopped for me to work? Does someone else also has this problem?.. Does this has something to do with the evaluation order? First the "other linker commands" and then the linker libraries? I use the latest trunk version of codeblocks...
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
As far as i can tell there libhunspell is also added after the wxSpellChecker library:
libtool: link: g++ -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o .libs/DictionariesNeededDialog.o .libs/MySpellingDialog.o .libs/OnlineSpellChecker.o .libs/SpellCheckHelper.o .libs/SpellCheckSettingsPanel.o .libs/SpellCheckerConfig.o .libs/SpellCheckerPlugin.o .libs/StatusField.o .libs/Thesaurus.o .libs/ThesaurusDialog.o .libs/mythes.o .libs/wxThes.o -Wl,--whole-archive wxspellchecker/.libs/libwxSpellChecker.a -Wl,--no-whole-archive -Wl,-rpath -Wl,/home/user/codeblocks/git/codeblocks_sf/src/sdk/.libs -Wl,-rpath -Wl,/home/user/codeblocks/install2/lib ../../../sdk/.libs/libcodeblocks.so -L/usr/lib/x86_64-linux-gnu -lwx_gtk2u_aui-3.0 -lwx_gtk2u_propgrid-3.0 -lwx_gtk2u_richtext-3.0 -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lhunspell-1.6 -ltinyxml -lpthread -ldl -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/7/crtfastmath.o /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o -O2 -Wl,--no-undefined -pthread -pthread -Wl,-soname -Wl,libSpellChecker.so -o .libs/libSpellChecker.so
removed the unused things:
libtool: link: g++ -fPIC -DPIC -shared -nostdlib [...objectFiles...] -Wl,--whole-archive wxspellchecker/.libs/libwxSpellChecker.a -Wl,--no-whole-archive [...wxLibs...] -lhunspell-1.6 [...systemLibs...] [...libSearchPaths...] [...otherThings...] -Wl,-soname -Wl,libSpellChecker.so -o .libs/libSpellChecker.so
so the question remains, why does it work on your side... Can you post the linker command line for libSpellChecker.so ?
Can someone test this patch?
for me this fixes the building of codeblocks projects on linux
the additional changes are made by codeblocks automatically...
diff --git a/src/plugins/contrib/SpellChecker/SpellChecker_wx30-unix.cbp b/src/plugins/contrib/SpellChecker/SpellChecker_wx30-unix.cbp
index 90671136d..8a2037d90 100644
--- a/src/plugins/contrib/SpellChecker/SpellChecker_wx30-unix.cbp
+++ b/src/plugins/contrib/SpellChecker/SpellChecker_wx30-unix.cbp
@@ -49,12 +49,12 @@
<Option run_host_application_in_terminal="0" />
<Option projectCompilerOptionsRelation="2" />
<Compiler>
+ <Add option="-fPIC" />
<Add option="$(#CB_RELEASE_TYPE)" />
<Add option="`$(WX_CONFIG) --cflags`" />
<Add option="-fmessage-length=0" />
<Add option="-fexceptions" />
<Add option="-Winvalid-pch" />
- <Add option="-fPIC" />
<Add option="-DCB_PRECOMP" />
<Add option="-DcbDEBUG" />
<Add directory="wxspellchecker/include" />
@@ -64,8 +64,8 @@
</Compiler>
<Linker>
<Add option="`$(WX_CONFIG) --libs`" />
+ <Add option="-lwxSpellChecker" />
<Add option="`pkg-config hunspell --libs`" />
- <Add library="wxSpellChecker" />
<Add library="codeblocks" />
<Add directory="../../../devel30" />
</Linker>
diff --git a/src/plugins/contrib/source_exporter/Exporter_wx30-unix.cbp b/src/plugins/contrib/source_exporter/Exporter_wx30-unix.cbp
index d2c5e4a45..d6e32b05c 100644
--- a/src/plugins/contrib/source_exporter/Exporter_wx30-unix.cbp
+++ b/src/plugins/contrib/source_exporter/Exporter_wx30-unix.cbp
@@ -18,6 +18,11 @@
<Compiler>
<Add option="-DWXMAKINGLIB_PDFDOC" />
</Compiler>
+ <Linker>
+ <Add option="`$(WX_CONFIG) --libs`" />
+ <Add option="`pkg-config --libs fontconfig`" />
+ <Add option="-Wl,--no-undefined" />
+ </Linker>
</Target>
<Target title="default">
<Option output="../../../devel30/share/codeblocks/plugins/exporter" prefix_auto="1" extension_auto="1" />
@@ -30,7 +35,10 @@
<Option run_host_application_in_terminal="0" />
<Option projectLinkerOptionsRelation="2" />
<Linker>
- <Add library="libwxPdfDocument.a" />
+ <Add option="-lwxPdfDocument" />
+ <Add option="`$(WX_CONFIG) --libs base,core,xml`" />
+ <Add option="`pkg-config --libs fontconfig`" />
+ <Add option="-Wl,--no-undefined" />
</Linker>
<ExtraCommands>
<Add after="zip -j9 ../../../devel30/share/codeblocks/exporter.zip manifest.xml" />
@@ -47,16 +55,16 @@
<Compiler>
<Add option="-Wextra" />
<Add option="-Wall" />
+ <Add option="-std=c++11" />
+ <Add option="-fPIC" />
<Add option="$(#CB_RELEASE_TYPE)" />
<Add option="`$(WX_CONFIG) --cflags`" />
<Add option="`pkg-config --cflags fontconfig`" />
<Add option="-Winvalid-pch" />
<Add option="-fexceptions" />
- <Add option="-fPIC" />
<Add option="-DCB_PRECOMP" />
<Add option="-DcbDEBUG" />
<Add option="-DwxPDF_USE_WXMODULE=0" />
- <Add option="-std=c++11" />
<Add directory="../../../include" />
<Add directory="../../../include/tinyxml" />
<Add directory="../../../sdk/wxscintilla/include" />
@@ -66,9 +74,6 @@
<Add directory="wxPdfDocument/include" />
</ResourceCompiler>
<Linker>
- <Add option="`$(WX_CONFIG) --libs`" />
- <Add option="`pkg-config --libs fontconfig`" />
- <Add option="-Wl,--no-undefined" />
<Add library="codeblocks" />
<Add directory="../../../devel30" />
</Linker>
[EDIT:] So there are two project files that need a fix the spell checker and the exporter.
I do not know why, but now i can not even compile the main project because of link library order:
g++ -shared -Ldevel30 .objs30/sdk/configmanager-revision.o .objs30/sdk/annoyingdialog.o .objs30/sdk/autodetectcompilers.o .objs30/sdk/base64.o .objs30/sdk/blockallocated.o .objs30/sdk/cbart_provider.o .objs30/sdk/cbauibook.o .objs30/sdk/cbcolourmanager.o .objs30/sdk/cbdebugger_interfaces.o .objs30/sdk/cbeditor.o .objs30/sdk/cbeditorprintout.o .objs30/sdk/cbexception.o .objs30/sdk/cbplugin.o .objs30/sdk/cbproject.o .objs30/sdk/cbstatusbar.o .objs30/sdk/cbstyledtextctrl.o .objs30/sdk/cbthreadpool.o .objs30/sdk/cbtreectrl.o .objs30/sdk/cbworkspace.o .objs30/sdk/ccmanager.o .objs30/sdk/compileoptionsbase.o .objs30/sdk/compiler.o .objs30/sdk/compilercommandgenerator.o .objs30/sdk/compilerfactory.o .objs30/sdk/compileroptions.o .objs30/sdk/compiletargetbase.o .objs30/sdk/configmanager.o .objs30/sdk/configurationpanel.o .objs30/sdk/configuretoolsdlg.o .objs30/sdk/confirmreplacedlg.o .objs30/sdk/crc32.o .objs30/sdk/debuggermanager.o .objs30/sdk/editarrayfiledlg.o .objs30/sdk/editarrayorderdlg.o .objs30/sdk/editarraystringdlg.o .objs30/sdk/editor_hooks.o .objs30/sdk/editorbase.o .objs30/sdk/editorcolourset.o .objs30/sdk/editorlexerloader.o .objs30/sdk/editormanager.o .objs30/sdk/editpairdlg.o .objs30/sdk/editpathdlg.o .objs30/sdk/edittooldlg.o .objs30/sdk/encodingdetector.o .objs30/sdk/externaldepsdlg.o .objs30/sdk/filefilters.o .objs30/sdk/filegroupsandmasks.o .objs30/sdk/filemanager.o .objs30/sdk/findreplacedlg.o .objs30/sdk/genericmultilinenotesdlg.o .objs30/sdk/globals.o .objs30/sdk/importers_globals.o .objs30/sdk/incremental_select_helper.o .objs30/sdk/infowindow.o .objs30/sdk/loggers.o .objs30/sdk/logmanager.o .objs30/sdk/macrosmanager.o .objs30/sdk/manager.o .objs30/sdk/menuitemsmanager.o .objs30/sdk/mozilla_chardet/src/CharDistribution.o .objs30/sdk/mozilla_chardet/src/JpCntx.o .objs30/sdk/mozilla_chardet/src/LangBulgarianModel.o .objs30/sdk/mozilla_chardet/src/LangCyrillicModel.o .objs30/sdk/mozilla_chardet/src/LangGreekModel.o .objs30/sdk/mozilla_chardet/src/LangHebrewModel.o .objs30/sdk/mozilla_chardet/src/LangHungarianModel.o .objs30/sdk/mozilla_chardet/src/LangThaiModel.o .objs30/sdk/mozilla_chardet/src/nsBig5Prober.o .objs30/sdk/mozilla_chardet/src/nsCharSetProber.o .objs30/sdk/mozilla_chardet/src/nsEscCharsetProber.o .objs30/sdk/mozilla_chardet/src/nsEscSM.o .objs30/sdk/mozilla_chardet/src/nsEUCJPProber.o .objs30/sdk/mozilla_chardet/src/nsEUCKRProber.o .objs30/sdk/mozilla_chardet/src/nsEUCTWProber.o .objs30/sdk/mozilla_chardet/src/nsGB2312Prober.o .objs30/sdk/mozilla_chardet/src/nsHebrewProber.o .objs30/sdk/mozilla_chardet/src/nsLatin1Prober.o .objs30/sdk/mozilla_chardet/src/nsMBCSGroupProber.o .objs30/sdk/mozilla_chardet/src/nsMBCSSM.o .objs30/sdk/mozilla_chardet/src/nsSBCharSetProber.o .objs30/sdk/mozilla_chardet/src/nsSBCSGroupProber.o .objs30/sdk/mozilla_chardet/src/nsSJISProber.o .objs30/sdk/mozilla_chardet/src/nsUniversalDetector.o .objs30/sdk/mozilla_chardet/src/nsUTF8Prober.o .objs30/sdk/multiselectdlg.o .objs30/sdk/newfromtemplatedlg.o .objs30/sdk/personalitymanager.o .objs30/sdk/pipedprocess.o .objs30/sdk/pluginmanager.o .objs30/sdk/pluginsconfigurationdlg.o .objs30/sdk/printing_types.o .objs30/sdk/projectbuildtarget.o .objs30/sdk/projectfile.o .objs30/sdk/projectfileoptionsdlg.o .objs30/sdk/projectlayoutloader.o .objs30/sdk/projectloader.o .objs30/sdk/projectloader_hooks.o .objs30/sdk/projectmanager.o .objs30/sdk/projectsfilemasksdlg.o .objs30/sdk/projecttemplateloader.o .objs30/sdk/scripting/bindings/sc_consts.o .objs30/sdk/scripting/bindings/sc_dialog.o .objs30/sdk/scripting/bindings/sc_globals.o .objs30/sdk/scripting/bindings/sc_io.o .objs30/sdk/scripting/bindings/sc_plugin.o .objs30/sdk/scripting/bindings/sc_progress.o .objs30/sdk/scripting/bindings/sc_util_dialogs.o .objs30/sdk/scripting/bindings/sc_wxtypes.o .objs30/sdk/scripting/bindings/scriptbindings.o .objs30/sdk/scriptingmanager.o .objs30/sdk/scriptsecuritywarningdlg.o .objs30/sdk/scrollingdialog.o .objs30/sdk/sdk_events.o .objs30/sdk/searchresultslog.o .objs30/sdk/selecttargetdlg.o .objs30/sdk/templatemanager.o .objs30/sdk/tinywxuni.o .objs30/sdk/toolsmanager.o .objs30/sdk/uservarmanager.o .objs30/sdk/workspaceloader.o .objs30/sdk/xtra_res.o -o devel30/libcodeblocks.so -L/usr/lib/x86_64-linux-gnu -pthread -lwx_gtk2u_aui-3.0 -lwx_gtk2u_propgrid-3.0 -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -Wl,--no-undefined -lgdk-x11-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -ltxml -lsqplus -lsqstdlib -lsquirrel -lwxscintilla_cb
devel30/libwxscintilla_cb.a(ScintillaWX.o): In function `ScintillaWX::DoKeyDown(wxKeyEvent const&, bool*)':
/home/codeblocks/codeblocks/src/sdk/wxscintilla/src/ScintillaWX.cpp:1212: undefined reference to `gdk_display_get_default'
/home/codeblocks/codeblocks/src/sdk/wxscintilla/src/ScintillaWX.cpp:1212: undefined reference to `gdk_keymap_get_for_display'
/home/codeblocks/codeblocks/src/sdk/wxscintilla/src/ScintillaWX.cpp:1215: undefined reference to `gdk_keymap_lookup_key'
obviously -lgdk-x11-2.0 should be after -lwxscintilla_cb