Recent

Author Topic: [Solved] Hunspell - can't get libhunspell.so to load  (Read 4154 times)

tcmdvm

  • New Member
  • *
  • Posts: 16
[Solved] Hunspell - can't get libhunspell.so to load
« on: January 26, 2017, 09:09:47 pm »
I am trying to get hunspell to work in linux. I have attached the project I have been working on.

It will work in windows, but I can't get it to work in linux.

I think the problem is that the libhunspell.so library is not being loaded. I have tried several ways to set the location to the library and nothing works.

May be someone can look at the code and see what is wrong.

I am using lazarus 1.60 + fixes and fpc 3.02.
« Last Edit: January 27, 2017, 11:15:22 pm by tcmdvm »

balazsszekely

  • Guest
Re: Hunspell - can't get libhunspell.so to load
« Reply #1 on: January 26, 2017, 09:28:30 pm »
Hi tcmdvm,

You should debug your package and find out where it fails, but first add $(IDEBuildOptions) to the Custom Options of  the package. From where I can download that libhunspell.so library? Can you upload somewhere?

regards,
GetMem

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Hunspell - can't get libhunspell.so to load
« Reply #2 on: January 26, 2017, 10:10:25 pm »
Make sure the path of the library is right and that it matches (32-bit "exe", 32-bit so and 64-bit "exe" 64 bit so)

stracing sometimes also gives a hunch

tcmdvm

  • New Member
  • *
  • Posts: 16
Re: Hunspell - can't get libhunspell.so to load
« Reply #3 on: January 26, 2017, 11:10:43 pm »
I am using the libhunspell.so from Archlinux. You can download a copy of the 64-bit library from their website.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: Hunspell - can't get libhunspell.so to load
« Reply #4 on: January 27, 2017, 10:07:06 am »
Check if the library is installed:

32-bit /usr/lib
64-bit /usr/lib64

Next check the library name, because it is common for linux renamed it by added a number, like libhunspell.so.1 or libhunspell.so.2.

Create a symbolic link libhunspell.so to library.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tcmdvm

  • New Member
  • *
  • Posts: 16
Re: Hunspell - can't get libhunspell.so to load
« Reply #5 on: January 27, 2017, 06:04:54 pm »
I have ran a trace of the code. It appears to load the library and goes through the following code:

Code: [Select]
@hunspell_initialize := GetProcAddress(DLLHandle, 'hunspell_initialize');
    if not Assigned(@hunspell_initialize) then Result := False;
    @hunspell_uninitialize := GetProcAddress(DLLHandle, 'hunspell_uninitialize');
    if not Assigned(@hunspell_uninitialize) then Result := False;
    @hunspell_spell := GetProcAddress(DLLHandle, 'hunspell_spell');
    if not Assigned(@hunspell_spell) then Result := False;
    @hunspell_suggest := GetProcAddress(DLLHandle, 'hunspell_suggest');
    if not Assigned(@hunspell_suggest) then Result := False;
    @hunspell_suggest_auto := GetProcAddress(DLLHandle, 'hunspell_suggest_auto');
    if not Assigned(@hunspell_suggest_auto) then Result := False;
    @hunspell_suggest_free := GetProcAddress(DLLHandle, 'hunspell_suggest_free');
    if not Assigned(@hunspell_suggest_free) then Result := False;
    @hunspell_get_dic_encoding := GetProcAddress(DLLHandle, 'hunspell_get_dic_encoding');
    if not Assigned(@hunspell_get_dic_encoding) then Result := False;
    @hunspell_put_word := GetProcAddress(DLLHandle, 'hunspell_put_word');
    if not Assigned(@hunspell_put_word) then Result := False;

It then goes through the procedure TSpellCheck.GetSuggestions where it is set Not Active and then it
exits.

It appears to be a problem somewhere in the code that is not reading the information from the library.
« Last Edit: January 27, 2017, 09:33:13 pm by tcmdvm »

tcmdvm

  • New Member
  • *
  • Posts: 16
Re: Hunspell - can't get libhunspell.so to load
« Reply #6 on: January 27, 2017, 11:12:53 pm »
Well I solved my own problem. I found some more code online that fixed the problem. I still don't see what was wrong in the old project.

The code contains a wrapper for hunspell as well as hyphen. You will have to set the library and dictionary locations.

Maybe someone else will find the code helpful.

 

TinyPortal © 2005-2018