[SOLVED] Cannot load library file using LoadLibrary() in Lazarus on Linux lazarus / 21-General ---------------------------------------------------------------------- Codrut1001 · 2023-11-20 16:13 I would like to use the Bass audio library in Lazarus for linux, I have the ".so" files and the units, but when I try to run the application, I get an error. The error occurs at the LoadLibrary() function. This is the error: The file "/build/glibc-BHL3KM/glibc-2.31/elf/dl-error-skeleton.c" was not found. Do you want to locate it yourself? I think this may be something with the compiler Itself, as It's not necessarily an error. For some reason, It cannot find a file. I am using the "dynlibs" unit for the library loading related functions. Any help would be greatly appreciated! ---------------------------------------------------------------------- rvk · 2023-11-20 16:21 Where did you put the libbass.so file ? From the BASS documentation: QuoteLinux version ------------- The LIBBASS.SO file needs to be in the OS's library search path for it to be found; simply placing it in the same directory as the executable won't necessarily work as it does on other platforms. The BASS libraries should also not be placed in the standard library directories to avoid version conflicts. To meet those competing requirements, a wrapper script could be used to set the "LD_LIBRARY_PATH" environment variable before loading the executable. Another option is to set the "rpath" in the executable to tell it where to look for libraries, which is what the example makefiles do. When building for multiple architectures, it is possible to simply try linking with all LIBBASS.SO versions, and the linker will use the appropriate one and ignore the others. ---------------------------------------------------------------------- Codrut1001 · 2023-11-20 16:58 Quote from: rvk on November 20, 2023, 05:21:18 pmWhere did you put the libbass.so file ? I placed the libbass.so file in the same directory as the executable. I also tried placing it in "/usr/bin", with the result being the same. Also, using the LoadLibrary() with any string still opens the same dialog, with the missing "dl-error-skeleton.c" file, so I still believe Lazarus is not configured properly. ---------------------------------------------------------------------- rvk · 2023-11-20 17:09 Quote from: Codrut1001 on November 20, 2023, 05:58:35 pmI placed the libbass.so file in the same directory as the executable. I also tried placing it in "/usr/bin", with the result being the same.Well, according to the doc I quoted that is wrong. Is /usr/bin in your OS path? You could also set the rpath. Read the quoted part. Quote from: Codrut1001 on November 20, 2023, 05:58:35 pmAlso, using the LoadLibrary() with any string still opens the same dialog, with the missing "dl-error-skeleton.c" file, so I still believe Lazarus is not configured properly. It's not Lazarus. Could be that the .so can be found (but read above) but that there is something missing in your OS (the correct glibc libs for example). But first try the correct lib location or set it correctly. ---------------------------------------------------------------------- Codrut1001 · 2023-11-20 17:45 Quote from: rvk on November 20, 2023, 06:09:38 pmIt's not Lazarus. Could be that the .so can be found (but read above) but that there is something missing in your OS (the correct glibc libs for example). But first try the correct lib location or set it correctly. When I have a break-point on this line, the error appears, when I don't, the error does not appear, but FBassDLL is 0 FBassDLL := LoadLibrary(PChar(BassDLL)); "/usr/bin/" is indeed in $PATH Also, this (https://forum.lazarus.freepascal.org/index.php?topic=45274.0l) question on the form also confirms that It's a debugger issue. But FBassDLL is 0 after LoadLibrary(), and since the debugger is unable to provide a error message, I can't load the library. :/ ---------------------------------------------------------------------- rvk · 2023-11-20 17:51 LoadLibrary just takes a unicodestring or rawbytestring. https://www.freepascal.org/docs-html/rtl/dynlibs/loadlibrary.html So you can just do Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FBassDLL := LoadLibrary(BassDLL); I'm not sure if your pchar gets cyber automatically back to a string. What happens to FBassDLL if you do that. (BassDLL should only contain the filename, not the path) ---------------------------------------------------------------------- Codrut1001 · 2023-11-20 17:57 Quote from: rvk on November 20, 2023, 06:51:42 pmSo you can just do Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FBassDLL := LoadLibrary(BassDLL); FBassDLL is still 0. I also tried SafeLoadLibrary(), with the same result. ---------------------------------------------------------------------- rvk · 2023-11-20 18:05 What does GetLoadErrorStr return after LoadLibrary? https://www.freepascal.org/docs-html/rtl/dynlibs/getloaderrorstr.html ---------------------------------------------------------------------- Codrut1001 · 2023-11-20 18:18 Quote from: rvk on November 20, 2023, 07:05:51 pmWhat does GetLoadErrorStr return after LoadLibrary? https://www.freepascal.org/docs-html/rtl/dynlibs/getloaderrorstr.html The file could not be found. From this, I was able to figure out that the file "libbass.so" needed to be placed in "/usr/lib", instead of "/usr/bin", I didn't check that properly since I have not developed many apps for linux before. Also, as a side note, in case anyone else stumbles upon this, on linux the BASS_UNICODE flag should not be used! Thank you so much! ---------------------------------------------------------------------- Чебурашка · 2023-11-20 20:44 The default is to call LoadLibrary supplying the library name only, and that requires the library to be in a valid search location (and pay attention that some distributions add version to library name libABC.so.1.2.3, in such a case a symlink libABC.so -> libABC.so.1.2.3 helps). Another way is to call your program with a suitable LD_LIBRARY_PATH env variable, for example if the library is in current directory > LD_LIBRARY_PATH=. ./myprogram will work. Another way is to supply to LoadLibrary the library file full path: LoadLibrary('/usr/local/mylibs/libABC.so'); in the case the search mechanism will not be applied and only the absolute path is used.