Cannot connect to MariaDB with ZConnection Component under macOS lazarus / 16-Databases ---------------------------------------------------------------------- Tomki · 2023-06-05 11:28 Hello all after a while break I rediscovered Lazarus and try to port older Delphi projects (still from Windows) to Lazarus under macOS and modernize them. I want to create a client for a MariaDB running on a QNAP NAS. The DB is set up and I can access it with myPHPAdmin and mySQL Workbench ... so far so good. I am using a Mac Pro (Intel macOS 12) and a MacBook (M1, macOS 13). I can also access a few other Macs (with Intel CPU) to test things. Now what happens is this. For starters, I simply try to connect to MariaDB via a ZConnection component of ZEOS. On the Mac Pro, this works without any grumbling. Same project on the MacBook (same Lazarus environment, mySQL installed) and I always get the same error: "libmysq|client.dylib found but could not be loaded. Check compile- target and library compatibility!. " I am still in the IDE - nothing compiled. On Mac Pro it works - on all other Macs the error comes.  :oops: The lib is available. I also copied it to the project folder and also referenced the lib directly with the "LibraryLocation" property. When trying it out, I tried different versions of the mySQLClient.dylib. Always the same error on all Macs except the Mac Pro!!! I can't find any help in the various wikis or forums. Does anyone here have any ideas? I have attached a screenshot. Thanks in advance! ---------------------------------------------------------------------- marsupilami79 · 2023-06-06 10:51 Hello Tomki, Quote from: Tomki on June 05, 2023, 01:28:05 pm"libmysq|client.dylib found but could not be loaded. Check compile-target and library compatibility!. " Zeos will generate that exception if it can find the library but cannot load it for some reason. What happens if you do something like tis: Code: [Select]procedure TestLibrayLoading; var   Handle: THandle: begin   Handle := LoadLibrary(PChar('/Users/thomas/Documents/work/Pascal/sql- test/libmysqlclient.21.dylib'));   if Handle = 0 then     RaiseLastOsError   else     ShowMessage('Library loaded successfully.'); end; Maybe this gives some more information on what happens. Also you might want to check if all dependencies of libmysqlclient.21.dylib are available. On Linux one can use ldd to check which other libraries are necessary. Best regards, Jan ---------------------------------------------------------------------- Tomki · 2023-06-07 07:28 Thanks Jan I tried and attached you can see the result. But I swear: the file is there! Regards Thomas ---------------------------------------------------------------------- Zvoni · 2023-06-07 07:32 is the dylib just copied over, or is it compiled for M1 (ARM)? What's YOUR Compile-Target in your Project? ---------------------------------------------------------------------- Tomki · 2023-06-07 07:33 Different question: I did not only copy the libmysqlclient.21.dylib into the project directory, but all of the *.dylib files. Is there anything else which I need to do? In a different scenario I pointed the LibraryLocation of the TZConnection component to the /usr/local/ folder in which the mySQL libs were placed at installation. /usr/local/mysql-8.0.33-macos13-x86_64/lib/libmysqlclient.21.dylib In this case it works! But I cannot make an application bundle, if it doesn't work if the lib location is different!? Thomas ---------------------------------------------------------------------- Tomki · 2023-06-07 07:35 Quote from: Zvoni on June 07, 2023, 09:32:58 amis the dylib just copied over, or is it compiled for M1 (ARM)? What's YOUR Compile-Target in your Project? it's just copied from the install directory of mySQL! See above addition... ---------------------------------------------------------------------- Tomki · 2023-06-07 07:38 Quote from: Zvoni on June 07, 2023, 09:32:58 amis the dylib just copied over, or is it compiled for M1 (ARM)? What's YOUR Compile-Target in your Project? compile targets are left on "default". However, this problem persists on M1 and on Intel based Macs... The initial setup is identical (as far as I can judge this) ---------------------------------------------------------------------- Zvoni · 2023-06-07 07:42 Access-Rights on the dylib itself? I don't remember anymore on *Nix if you have to set "executable"-Flag and/or Access-Flags if you copy a file from a "protected" Folder ---------------------------------------------------------------------- Tomki · 2023-06-07 07:46 I look at the information about both files. See attached. Sorry, but I am not an expert on "system level"  Difference appears to be the "owner" ---------------------------------------------------------------------- Tomki · 2023-06-07 08:35 Zvoni, now I think it must have to do with access rights or something like that deep in the system which I don't understand  I copied the lib libmysqlclient.21.dylib from another application into my project folder. I found out that all the libs are contained in the "Frameworks" folder of the mySQLWorkbench application. So I used this one and now I have the following effect: I point the LibraryLocation to this lib file which I copied from the mySQLWorkbench.app/Frameworks and in the Lazarus Designer I get the same old error message (file found, but can't load) - but if I compile the project (no other change) it work's without error during runtime!?!?! To me there is no difference in the access rights of the newly copied file, but obviously there must be some difference in the background. So now, what is the difference and why does it not work in Designtime but in runtime? ---------------------------------------------------------------------- TRon · 2023-06-07 08:42 Quote from: Tomki on June 07, 2023, 10:35:23 amSo now, what is the difference and why does it not work in Designtime but in runtime? It is possible that you installed Lazarus as another user/owner. Some people install/run Lazarus as admin/root/userX (don't ask me why) while you "the normal user" invoked the compiled application from the OS (not through Lazarus). That also applies to/for mariaDB (admin users can do more/other things with the DB manager). There is a distinct difference in such cases (user access rights). Unfortunately I am not familiar with the platform to such extend that I can make any (additional) suggestions. Does MacOS has something like the strace utility for Linux ? ---------------------------------------------------------------------- Tomki · 2023-06-07 09:01 Hi TRon Thank's for your reply, but no, not that I know of ---------------------------------------------------------------------- TRon · 2023-06-07 09:10 Quote from: Tomki on June 07, 2023, 11:01:32 amHi TRon Thank's for your reply, but no, not that I know of  Seems it is called dtruss ? or install strace using brew ? see also: https://stackoverflow.com/questions/73724074/how-to-call-an- equivalent-command-to-strace-on-mac-ideally-from-python (ignore the python parts and what the original question is asking: look at the suggestion for utilities/workarounds to use a trace tool such as strace, dtrace, exesnoop etc though your mileage might vary due to security reasons). edit: the point in asking is that a utility like strace is able to show you what the application is doing at runtime (loading files/libraries) and what other files the executable drags in during execution (also indirect loading of additional libraries/dependencies/configuration files etc) and report if that succeeded and/or failed. Even something like a tool like a dll dependency walker (on Windows) is able to show the dependencies a library has. It would be able to better pinpoint the issue you seem to be facing. Unless ofc. someone has a better idea ? ---------------------------------------------------------------------- Tomki · 2023-06-17 17:00 I now tried everything … install_name_tool …. otool … as described and still no success. Different approach: Did anyone build a macOS app with mysql and a correspomding application bundle? Can any tell me what to do to make the app connect to a mysql (or mariadb server)? I guess I‘ll open a new threat woth this question…