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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2361
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: 11770
    • 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: 2361
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: 11770
    • 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: 2361
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: 11770
    • 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: 95
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: 2361
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: 11770
    • 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: 95
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: 2361
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: 2361
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?