Recent

Author Topic: Location & name of libmysqlclient.dylib on MacOS  (Read 5442 times)

christchurchuser

  • Newbie
  • Posts: 3
Location & name of libmysqlclient.dylib on MacOS
« on: May 11, 2017, 04:40:26 pm »
Hi All,

Sorry if this has been asked in the past, but I haven't been able to find an answer.

I am using Lazarus 1.6.4, and FPC 3.0.0

I have a Lazarus application (on Ubuntu, works OK compiling on Windows as well), which accesses a MySQL DB using the builtin mysqldb components.

Program compiles fine on the Mac but when I try to connect to the DB it complains that it can't find libmysqlclient.dylib.18 or libmysqlclient.dylib,
problem one is the filename as on the mac the file list libmysqlclient.18.dylib, so OK just symlink.
problem two is where does the file go? have tried various locations (/usr/lib, same directory as the executable....), but it doesn't find it. I have also tried setting LD_LIBRARY_PATH & DYLD_LIBRARY_PATH but to no avail.

Could one of the wonderful guru's out there please point me in the right direction as I seem to be going round and round in circles.

Thanks in advance.
   

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Location & name of libmysqlclient.dylib on MacOS
« Reply #1 on: May 11, 2017, 05:16:48 pm »
Program compiles fine on the Mac but when I try to connect to the DB it complains that it can't find libmysqlclient.dylib.18 or libmysqlclient.dylib,

Review the MySQL source and see how it's linking to or loading the library. There are probably two ways the source can be compiled, with linklib or so it uses LoadLibrary (loading the library "dynamically").

Since MySQL is not a standard library on OS X, you'll probably want to include the .dylib in your app's bundle, in the Frameworks subfolder.


christchurchuser

  • Newbie
  • Posts: 3
Re: Location & name of libmysqlclient.dylib on MacOS
« Reply #2 on: May 11, 2017, 06:10:34 pm »
Phil,

Thanks for the fast reply.

the mysqldb component uses dynamic(runtime) loading using LoadLibrary. I have already been there. However it doesn't set any distinct paths to the library, relying on the OS to sort it out. Works fine with Linux and Windows they find it fine (as long as you put it in the right place).

Haven't tried using the Frameworks Folder, so will give this a go, Since your message I can see that that is where MySQLWorkbench has the library loaded. So I will give that a try.


Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Location & name of libmysqlclient.dylib on MacOS
« Reply #3 on: May 11, 2017, 06:17:49 pm »
Haven't tried using the Frameworks Folder, so will give this a go, Since your message I can see that that is where MySQLWorkbench has the library loaded. So I will give that a try.

That's the .app bundle's Frameworks subfolder, NOT the system's. However, in this case if you think it's relying on the OS default locations, then you need to study up on that. It's possible that the code just doesn't work, I suppose. I doubt if MySQL is used much on Mac. Certainly I don't think I've ever run across an app that uses it. Since Sqlite is a standard library on all Macs and all iOS devices, that's used quite commonly.

Typically apps include the libraries they need as part of their .app bundles. That way the user doesn't have to install anything else and the app is self-contained. See how the apps on your Mac do it, eg, iTunes.app.

« Last Edit: May 11, 2017, 06:21:33 pm by Phil »

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: Location & name of libmysqlclient.dylib on MacOS
« Reply #4 on: December 19, 2022, 05:51:11 am »
I'm stuck on this. trying to open a dataset that uses TMySQLConnection80, I get :

[Debugger Exception Notification]


[Break]
Project FHIRServer raised exception class 'EInOutError' with message:
Can not load default MySQL library (\"libmysqlclient.dylib.21\" or \"libmysqlclient.dylib\"). Check your installation.

 At address 10014C8B0


[Ignore this exception type]

[Continue]

I have a copy of the dylib all over the place, including in the .app package, but it still can't find it. Can I configure it? Where should it be?

 

TinyPortal © 2005-2018