Author Topic: BASSenc Linux x64 binary cannot be loaded by LoadLibrary with error code 20  (Read 126 times)

TDDung

  • Posts: 15
Dear Ian,

In my effort to complete a multi-framework and multi-platform binding of BASS + BASSenc and add-ons for Delphi (Which I will share on Github so everyone can benefit from your excellent BASS library :)), I found that that Linux x64 binary from http://www.un4seen.com/download.php?bassenc24-linux cannot be dynamically loaded with returned error 20. Would you please help check and give some suggestions?

Note: I did try hard but cannot find any other binary to replace yours, thus I must ask for your help.

Ian @ un4seen

  • Administrator
  • Posts: 23545
Please clarify where the error code 20 is coming from, ie. what function. If you happen to be trying to use BASS_PluginLoad to load BASSenc then please note that isn't possible because BASS_PluginLoad only deals with add-ons that add support for additional file formats (it plugs them into BASS_StreamCreateFile/etc).

TDDung

  • Posts: 15
Oh I did not say correctly, sorry.

When I dynamically load the libbassenc.so by LoadLibrary, the return value is 0. The code 20 came from GetLastError.

Code: [Select]
FBassEncDLL := LoadLibrary(PChar(BassEnc_Lib));
  if FBassEncDLL = 0 then
  begin
    LastError := GetLastError;
    Exit;
  end;

  BASS_Encode_GetVersion:= GetProcAddress(FBassEncDLL, PChar('BASS_Encode_GetVersion'));
  BASS_Encode_Start:= GetProcAddress(FBassEncDLL, PChar('BASS_Encode_Start'));
...

(BassEnc_Lib is the full path name to libbassenc.so)

The binaries for Android, Windows, ... all loaded OK and work as expected.

I did try SafeLoadLibrary (as it preserves current FPU control word) also but got the same result.

PS: Is there a more recent binary than this http://www.un4seen.com/download.php?bassenc24-linux ?
« Last Edit: 30 Apr '21 - 18:38 by TDDung »

TDDung

  • Posts: 15
Hi Ian,

By taking your advice in BASS.TXT for using BASS in Linux (Specifically LD_LIBRARY_PATH) and in https://www.un4seen.com/forum/?topic=19359.0 (Specifically about the link between BASSenc and BASS and the need to have BASS's path known to Linux OS), I have successfully loaded and used BASSenc in Linux x64.

Ian @ un4seen

  • Administrator
  • Posts: 23545
Good to hear that you've found a solution. I guess you're using a script to set LD_LIBRARY_PATH before loading your app? If Delphi supports custom linker options then you could try setting "rpath" to "$ORIGIN" instead, which tells Linux to look for libraries in the executable's folder (like Windows does). I think that's a nicer solution, as there's no need for extra scripts. It's what the example makefile included in the Linux BASS package does.

TDDung

  • Posts: 15
Thank you Ian, that's exactly what I did (Started from LD_LIBRARY_PATH and settled on rpath :))