Author Topic: Compiling SpellChecker on linux  (Read 2354 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2492
Compiling SpellChecker on linux
« on: February 18, 2019, 09:59:46 am »
Hi,
if i try to compile the SpellChecker plugin on linux i get linker errors:
Code: [Select]
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
Code: [Select]
`$(WX_CONFIG) --libs`
-lwxSpellChecker
`pkg-config hunspell --libs`

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12002
    • Travis build status
Re: Compiling SpellChecker on linux
« Reply #1 on: February 18, 2019, 08:02:13 pm »
What is the difference in command lines between the two?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2492
Re: Compiling SpellChecker on linux
« Reply #2 on: February 18, 2019, 09:17:11 pm »
Hundspell  and wxSpellChecker change place...
Not working:
Code: [Select]
-lhunspell-1.6  -lwxSpellCheckerWorking
Code: [Select]
-lwxSpellChecker -lhunspell-1.6So the order matters for gcc (as we all know...)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12002
    • Travis build status
Re: Compiling SpellChecker on linux
« Reply #3 on: February 18, 2019, 10:13:19 pm »
It matter for the linker and not GCC! I guess it is safe to commit it. But for me it works fine. No idea why for you it doesn't work.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2492
Re: Compiling SpellChecker on linux
« Reply #4 on: February 19, 2019, 10:30:10 am »
Code: [Select]
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
Code: [Select]
-lA -lB
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...


Code: [Select]
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)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12002
    • Travis build status
Re: Compiling SpellChecker on linux
« Reply #5 on: February 19, 2019, 07:29:24 pm »
I'm running Gentoo and GCC 6.x. Does it build if you use autotools?
What you're saying about the order is correct.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline blauzahn

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: Compiling SpellChecker on linux
« Reply #6 on: February 19, 2019, 07:40:59 pm »
Quote
Configured with: ../src/configure
It seems like he does.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2492
Re: Compiling SpellChecker on linux
« Reply #7 on: February 19, 2019, 08:04:49 pm »
I can build it with autotools without problems...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12002
    • Travis build status
Re: Compiling SpellChecker on linux
« Reply #8 on: February 19, 2019, 08:46:23 pm »
Quote
Configured with: ../src/configure
It seems like he does.
Nope. This is from the gcc -v execution. GCC records the configure command, so when reporting bugs it will save some questions and back and forths.

@bluehazzard: Is the linking order different during linking with libtool?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline blauzahn

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: Compiling SpellChecker on linux
« Reply #9 on: February 19, 2019, 09:01:36 pm »
Quote
Nope. This is from the gcc -v execution
Sorry. Too tired to spot that immediately.

On my Ubuntu 18.04 I and can compile and link cb including SpellChecker plugin
via autotools

svn 11575, wx3.1.3,  gcc_7.3.0_Linux/unicode - 64 bit

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2492
Re: Compiling SpellChecker on linux
« Reply #10 on: February 20, 2019, 11:58:53 am »
As far as i can tell there libhunspell is also added after the wxSpellChecker library:
Code: [Select]
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:
Code: [Select]
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.soso the question remains, why does it work on your side... Can you post the linker command line for libSpellChecker.so ?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2492
Re: Compiling SpellChecker on linux
« Reply #11 on: May 12, 2019, 09:23:26 pm »
Ping.

Can some other on linux check if he has the same problem with compiling spell checker with codeblocks?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2492
Re: Compiling SpellChecker on linux
« Reply #12 on: July 25, 2019, 10:30:33 pm »
Can someone test this patch?
for me this fixes the building of codeblocks projects on linux

the additional changes are made by codeblocks automatically...

Code: [Select]
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.
« Last Edit: July 25, 2019, 10:34:00 pm by BlueHazzard »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2492
Re: Compiling SpellChecker on linux
« Reply #13 on: August 20, 2019, 09:42:32 pm »
@Obfuscated: can you test the patch on your system and tell me if it compiles? So i can close this...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12002
    • Travis build status
Re: Compiling SpellChecker on linux
« Reply #14 on: August 25, 2019, 05:16:16 pm »
I'm on windows for now...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]