Recent

Author Topic: Can not load default MySQL library - Mac OS X  (Read 24140 times)

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Can not load default MySQL library - Mac OS X
« on: April 27, 2008, 03:24:33 pm »
Hi all,

I installed SQLdb and created a sample MySQL50Connection, but I got this
error while connection.

Can not load default MySQL library ("libmysqlclient.so.15" or "libmysqlclient.so"). Check your installation.

I also installed MySQL 5.0.

Thanks

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Can not load default MySQL library - Mac OS X
« Reply #1 on: April 27, 2008, 05:11:44 pm »
Quote from: "IndianaJones"
Hi all,

I installed SQLdb and created a sample MySQL50Connection, but I got this
error while connection.

Can not load default MySQL library ("libmysqlclient.so.15" or "libmysqlclient.so"). Check your installation.

I also installed MySQL 5.0.

Thanks


I would imagine this means that it can't find the library. Determine the location of this library to make sure you have it.

Are you calling InitializeMySql? There's an overloaded version of this function that allows you to pass in the complete library path; otherwise it just looks for libmysqlclient.so without a path.

Also, does your library have an .so or .dylib extension?

Thanks.

-Phil

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
RE: Re: Can not load default MySQL library - Mac OS X
« Reply #2 on: April 27, 2008, 05:24:09 pm »
Hi Phil,

My mysql libraries are located in the /usr/local/mysql/lib and they have .dylib extension.
For the InitializeMySql part, really i dont understand.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: Can not load default MySQL library - Mac OS X
« Reply #3 on: April 27, 2008, 05:46:58 pm »
Quote from: "IndianaJones"
Hi Phil,

My mysql libraries are located in the /usr/local/mysql/lib and they have .dylib extension.
For the InitializeMySql part, really i dont understand.


Looking in mysql.inc I see that the library name is determined at compile time like this:

{$IFDEF Unix}
  {$DEFINE extdecl:=cdecl}
  const
    mysqllib = 'libmysqlclient.so';
{$ENDIF}
{$IFDEF Windows}
  {$DEFINE extdecl:=stdcall}
  const
    mysqllib = 'libmysql.dll';
{$ENDIF}

Unix is defined for OS X too so this means it's looking for a library with an .so extension, whereas on OS X the library has a .dylib extension.

The mysql50conn unit calls InitializeMySql.

Offhand I would guess that this unit has never been tested on OS X.

I don't use MySQL so I don't have much more to offer. Maybe a bug report would be the next step for you to take.

Thanks.

-Phil

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
RE: Re: RE: Re: Can not load default MySQL library - Mac OS
« Reply #4 on: April 27, 2008, 07:37:28 pm »
Thanks Phil for the great info.
I posted a case for this.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: Can not load default MySQL library - Mac
« Reply #5 on: April 27, 2008, 08:04:02 pm »
Quote from: "IndianaJones"
Thanks Phil for the great info.
I posted a case for this.


I see that your same question was asked under Databases a while back and never answered. I think that verifies my suspicion that it's never worked with OS X. I wouldn't be surprised if that's true of about half the things included with FPC.

Thanks.

-Phil

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
RE: Re: RE: Re: RE: Re: Can not load default MySQL library -
« Reply #6 on: April 27, 2008, 10:54:52 pm »
Hi Phil,

Is there any component for mysql handling supported on the Mac OS X that you know?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: RE: Re: Can not load default MySQL libra
« Reply #7 on: April 27, 2008, 11:21:40 pm »
Quote from: "IndianaJones"
Hi Phil,

Is there any component for mysql handling supported on the Mac OS X that you know?


No, sorry, I don't.

Fixing mysql.inc might be as easy as changing this line:

mysqllib = 'libmysqlclient.so';

to this:

{$IFDEF DARWIN}
  mysqllib = '/usr/local/mysql/lib/libmysqlclient.dylib';
{$ELSE}
  mysqllib = 'libmysqlclient.so';
{$ENDIF}

I assume that /usr/local/mysql/lib is the standard place where the client library is installed.

Then you would also have to recompile mysql50conn and the Laz package. If you don't want to try that, you could suggest the above fix in a bug report.

Thanks.

-Phil

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
RE: Re: RE: Re: RE: Re: RE: Re: Can not load default MySQL l
« Reply #8 on: April 28, 2008, 04:17:44 pm »
Hi Phil,

The mentioned case resolved, but again Lazarus warn me about the same library problem.
So where is the default library path for the fpc? And if I add some library directories in the fpc.cfg that would be the solution?

Thanks

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: RE: Re: RE: Re: Can not load default MyS
« Reply #9 on: April 28, 2008, 05:43:40 pm »
Quote from: "IndianaJones"
Hi Phil,

The mentioned case resolved, but again Lazarus warn me about the same library problem.
So where is the default library path for the fpc? And if I add some library directories in the fpc.cfg that would be the solution?

Thanks


How exactly did you resolve it?

Are you getting a compile- or run-time warning?

mysql.inc calls LoadLibrary without specifying a path with the library file name, so I believe this means that the system path will be search. /usr/local/mysql/lib is not on the default OS X path, so you'll probably have to add it so the library is found at runtime. Your users will need to add this to their path too.

Thanks.

-Phil

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: Can not load default
« Reply #10 on: April 28, 2008, 08:54:27 pm »
Hi Phil,

I opened a case for this problem and Bug ID - 0011225 was resolved.

uses
{$IFDEF LinkDynamically}
     Dynlibs, sysutils,
{$ENDIF}
     ctypes;

added to the mysql.inc.
Is there a file like in Linux (ld.so.conf) which consists library paths on the Mac OS X?
Anyway PATH variable also consists /usr/local/mysql/lib directory if necessary.

Thanks

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: Can not load def
« Reply #11 on: April 28, 2008, 09:49:01 pm »
Quote from: "IndianaJones"
Hi Phil,

I opened a case for this problem and Bug ID - 0011225 was resolved.

uses
{$IFDEF LinkDynamically}
     Dynlibs, sysutils,
{$ENDIF}
     ctypes;

added to the mysql.inc.
Is there a file like in Linux (ld.so.conf) which consists library paths on the Mac OS X?
Anyway PATH variable also consists /usr/local/mysql/lib directory if necessary.

Thanks


I see that with FPC 2.2.1 and later, mysql.inc has changed some. What I was looking at yesterday was 2.2.0.

Not sure how what you cite fixes the problem, though.

You might review man ld and the like for library path info. If you have sogudi installed, man:ld in Safari will generate a page with the manual pages that you can scroll through, etc.

To change path, do it like here:

http://wiki.lazarus.freepascal.org/Carbon_interface_FAQ#I_get_error_.22make:_-iVSPTPSOTO:_Command_not_found.22_when_I_try_to_rebuild_LCL_or_Lazarus_IDE_for_Carbon_interface_via_terminal.

Are you using 2.2.1 or later for both PowerPC and Intel compiling?

Thanks.

-Phil

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: Can not load
« Reply #12 on: April 29, 2008, 04:14:06 pm »
Hi Phil,

Sorry for the late response, I solved the problem for Mac OS X.
Mac default library paths are /usr/lib and /usr/local/lib so I made a link in /usr/lib for libmysqlclient.dylib.
But the question is, Is there any other solution to add other directories to the default library path for Mac OS X?
Anyway I am using 2.3.1. FYI I tested a simple sql50connection and works quite well.

Thanks for the response and a clue for that.

Jaco

  • New Member
  • *
  • Posts: 45
RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: Can not load
« Reply #13 on: April 30, 2008, 02:20:37 pm »
Great to see this solution... a couple of weeks ago I stumbled upon the same problem.
A question, though, remains for me: how do I use the 2.3.1 fpc, since 2.2.0 comes with the snapshots.
Can I simply download the source, and overwrite the fpc directory Laz is using ?

Thanks,

Jaco

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: Can not load
« Reply #14 on: April 30, 2008, 03:16:46 pm »
Hi Jaco

I sent a post which name is FPC 2.3.1 and SQLDBLaz Installation on Mac OS X.
In this post i gave a simple instruction, you can follow the procedure.

 

TinyPortal © 2005-2018