Author Topic: .NET Core on Ubuntu / Bassenc cannot be loaded  (Read 142 times)

gian

  • Posts: 3
Hello there,
we've been developing a project that needs to stream audio from a number of mp3 files. Its running on .NET Core 3.1 and tested fully on Windows.
One of the requirements now is to have it run on Linux (testing on ubuntu 16.04) and, after a number of little retouch required we are stuck at an issue when loading libbassenc.so.

The code is fairly simple, just for testing:

Code: [Select]

dlopen( "libbass.so", RTLD_LAZY | RTLD_GLOBAL );
dlopen( "libbassmix.so", RTLD_LAZY | RTLD_GLOBAL );
dlopen( "libbassenc.so", RTLD_LAZY | RTLD_GLOBAL );
dlopen( "libbassenc_flac.so", RTLD_LAZY | RTLD_GLOBAL );
dlopen( "libbass_aac.so", RTLD_LAZY | RTLD_GLOBAL );
dlopen( "libbassalac.so", RTLD_LAZY | RTLD_GLOBAL );

if( !Bass.BASS_Init( 0, 44100, BASSInit.BASS_DEVICE_DEFAULT | BASSInit.BASS_DEVICE_NOSPEAKER | BASSInit.BASS_DEVICE_MONO, IntPtr.Zero ) ) {
    LogError( "BASS >> INITIALIZATION >> FAILED!" );
    return;
}

Log( "BASS >> " + Bass.BASS_GetVersion() );
Log( "MIXER >> " + BassMix.BASS_Mixer_GetVersion( ) );
Log( "ISSUE ON INIT >> " + Bass.BASS_ErrorGetCode( ) );

Log( "ENCODER >> " + BassEnc.BASS_Encode_GetVersion( ) );
Log( "ISSUE ON INIT >> " + Bass.BASS_ErrorGetCode( ) );


As soon as we hit the BassEnc.BASS_Encode_GetVersion( ) on the log we get the following error:

Code: [Select]
Unable to load shared library 'bassenc' or one of its dependencies. [...] libbassenc: cannot open shared object file: no such file or directory

I believe there's some other library missing but can't really work out wich one. Any idea what shared object file could be missing here?

Ian @ un4seen

  • Administrator
  • Posts: 23662
Re: .NET Core on Ubuntu / Bassenc cannot be loaded
« Reply #1 on: 30 Apr '21 - 17:44 »
If the BASS_Mixer_GetVersion call is successful then my guess is that the issue is that the libbass.so file isn't in the library search path, because BASSenc links to the BASS library while BASSmix instead relies on it already being loaded (on Linux). The latter method has its own issue, so BASSmix will link to BASS in the next release too.

I guess you have the BASS libraries alongside your EXE? Windows automatically includes that folder in the library search path but Linux doesn't, ie. it needs to be told to look there. I'm not a .Net user myself, so I'm not sure but do you know if .NET Core 3.1 adds the EXE's folder to the library search path? If not, perhaps there's some way to tell it to do so?

serkanp

  • Posts: 95
Re: .NET Core on Ubuntu / Bassenc cannot be loaded
« Reply #2 on: 1 May '21 - 09:50 »
check linux version you are running..
x64 , x86 , armXX etc..
if your system is x64, all .so files must be x64 versions..
if your system is x86, then all .so files must be x86 version.. this is a common mistake..
get the latest versions from un4seen website and copy one by one..

put all .so files and libbass.so in the same folder of your exe.
i tested on arm7 , ubuntu x64 ,windows with .net core 5.0 and works without any problem.

prepare a small test app and send private message to me.. i'll help on finding problem..

TDDung

  • Posts: 19
Re: .NET Core on Ubuntu / Bassenc cannot be loaded
« Reply #3 on: 1 May '21 - 19:14 »
Hello,

Although I am using Delphi, it seems that I have the same problem when loading the libbassenc.so (x64) on Linux Ubuntu x64 (https://www.un4seen.com/forum/?topic=19356.0). Since I am very sure that libbassenc.so file is for Intel x64 (http://www.un4seen.com/download.php?bassenc24-linux) and it stays in the same place with libbass.so (x64) and libbass.so has been loaded + working OK prior to loading libbassenc.so, I hope to find some suggestions about possible causes and/or solutions.

On Android, which is very similar to Linux, the same setup and the same codes work perfectly OK (with libbass.so and libbassenc.so for Android, of course), thus it seems the libbassenc.so for Linux64 is what needs to be checked.

Any idea, please?

@serkanp Or can you share a piece of code that works on Linux x64 for you, please?

TDDung

  • Posts: 19
Re: .NET Core on Ubuntu / Bassenc cannot be loaded
« Reply #4 on: 2 May '21 - 18:10 »
Hello,

By taking Ian's advice in BASS.TXT for using BASS in Linux (Specifically LD_LIBRARY_PATH) and his reply above (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. Thanks.