Loading libbass.dylib via application bundle fails lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- stem · 2021-11-12 20:35 Hi, unfortunately I don't succeed in loading libbass.dylib via the Frameworks directory in my application bundle. 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 BASS_Handle := LoadLibrary(PChar('libbass.dylib')); BASS_Handle equals 0. I've made everything as it is explained in https://wiki.lazarus.freepascal.org/macOS_Dynamic_Libraries Does anyone have hints for me? Can I check in what places the application (bundle) is searching for the dynamic library? Thank you. stem ---------------------------------------------------------------------- winni · 2021-11-12 20:46 Hi! un4seen has a forum for BASS with a lot of knowledge like here: http://www.un4seen.com/forum/?topic=17383.0 Winni ---------------------------------------------------------------------- trev · 2021-11-12 23:40 Quote from: stem on November 12, 2021, 09:35:06 pmI've made everything as it is explained in https://wiki.lazarus.freepascal.org/macOS_Dynamic_Libraries Does anyone have hints for me? Are you sure you set the path to the library in the executable as I detailed in the article at Additional steps using a Lazarus project ? QuoteCan I check in what places the application (bundle) is searching for the dynamic library? Have you tried the various methods listed in that article in the section entitled Observe the dynamic linker in action especially using dtruss? ---------------------------------------------------------------------- stem · 2021-11-13 15:06 Yes, I've read the article before.  Thank you for the documentation, I appreciate it a lot! dtruss says: Code: [Select]stat64("/Volumes/xyz/binaries/macos/myapp.app/Contents/M acOS/../Frameworks/libbass.dylib\0", 0x7FFEE7BF2B60, 0x0) = 0 0 stat64("/Volumes/xyz/binaries/macos/myapp.app/Contents/MacOS/../Framew orks/libbass.dylib\0", 0x7FFEE7BF2FE0, 0x0) = 0 0 open("/Volumes/xyz/binaries/macos/myapp.app/Contents/MacOS/../Framewor ks/libbass.dylib\0", 0x0, 0x0) = 3 fcntl0 dtrace: error on enabled probe ID 2201 (ID 465: syscall::pread:return): invalid kernel access in action #12 at DIF offset 20 dtrace: error on enabled probe ID 2201 (ID 465: syscall::pread:return): invalid kernel access in action #12 at DIF offset 20 The executable seems to search for the dynamic library in the correct folder. But I'm not sure, if the last two lines have anything to do with my problem. Thank you! stem ---------------------------------------------------------------------- trev · 2021-11-14 00:23 What's the error message? I assume you have the handle failure code similar to this from my article: 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 else    // error message on load failure    ShowMessage('GetLastOSError2 = ' + SysErrorMessage(GetLastOSError)); The open() return code for the library is successful. I'm not sure why it fails to get a handle... is the library bitness correct? 64 bit? What does file /Volumes/xyz/binaries/macos/myapp.app/Contents/MacOS/.. /Frameworks/libbass.dylib. return? I don't think the last two lines are related, just macOS security blocking some dtruss kernel probes. ---------------------------------------------------------------------- stem · 2021-11-14 12:38 I've found out that the problem is that the following variable is nil: 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 @BASS_SetConfig:= GetProcAddress(BASS_Handle, PChar('BASS_SetConfig')); (which obviously means that this function is not correctly linked in) The error message is "operation not supported". I'm trying to find the error. (The same code and the library works perfectly with Windows and Linux.) P.S. Code: [Select]file /Volumes/xyz/binaries/macOS/myapp.app/Contents/MacO S/../Frameworks/libbass.dylib /Volumes/xyz/binaries/macOS/myapp.app/Contents/MacOS/../Frameworks/lib bass.dylib: Mach-O universal binary with 3 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [i386:Mach-O dynamically linked shared library i386] [arm64:Mach-O 64-bit dynamically linked shared library arm64] /Volumes/xyz/binaries/macOS/myapp.app/Contents/MacOS/../Frameworks/lib bass.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 /Volumes/xyz/binaries/macOS/myapp.app/Contents/MacOS/../Frameworks/lib bass.dylib (for architecture i386): Mach-O dynamically linked shared library i386 /Volumes/xyz/binaries/macOS/myapp.app/Contents/MacOS/../Frameworks/lib bass.dylib (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64 stem ---------------------------------------------------------------------- stem · 2021-11-14 13:25 I've solved the problem by changing 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 BASS_Handle : Thandle = 0; to 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 BASS_Handle : TLibHandle = 0; in the file Dynamic_Bass.pas that can be downloaded on the homepage of the project. Thank you. stem ---------------------------------------------------------------------- trev · 2021-11-14 21:06 My Wiki examples use TLibHandle - just another reminder that macOS is not Windows nor Linux Thanks for returning with the solution... many don't.