library problem on MAC OSX

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Post Reply
Cratouffe
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 05.10.2014, 14:15

library problem on MAC OSX

Post by Cratouffe »

Hi

I am trying to use zeoslib with Lazarus on a Mac OsX (Maverick) to manage a mysql database. When I try to connect I have the message:
None of the dynamic libraries can be found or is loadable. libmysqlclient.dylib.18,libmysqlclient.dylib.16,libmysqlclient.dylib.15,libmariadb.dylib,libmysqlclient.dylib
Use TZConnection.LibraryLocation if the location is invalid

I have downloaded from MySQL libmysqlclient.18.dylib (there is no libmysqlclient.dylib.18) and I have changed the TZConnection.LibraryLocation but it is still not working

Any ideas
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: library problem on MAC OSX

Post by EgonHugeist »

Ideas, Yes.

Which IDE you are using for? New Delphi?

Did you use TZConnection.LibraryLocation to let Zeos know which lib you want to use and where the file is located?

if yes and you are sure the path+lib-name are corect:

Check \core\ZPlainLoader.pas
function TZNativeLibraryLoader.ZLoadLibrary(Location: String): Boolean;

how is LoadLibrary on OsX decalred?`I don't know anybody who tested on OsX.
Next possible issue i see:

\ZPlain\ZPlainMySQLConstants.pas
All library call conventions are defined as:
{$IFNDEF UNIX} stdcall {$ELSE} cdecl {$ENDIF}
personally i think
{$IFDEF MSWINDOWS} stdcall {$ELSE} cdecl {$ENDIF}
would be right.

Can you check my suggestions?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Cratouffe
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 05.10.2014, 14:15

Re: library problem on MAC OSX

Post by Cratouffe »

EgonHugeist wrote: Which IDE you are using for? New Delphi?
Lazarus
EgonHugeist wrote: Did you use TZConnection.LibraryLocation to let Zeos know which lib you want to use and where the file is located?
if yes and you are sure the path+lib-name are corect:
Yes I did it here is a part of my code.

Code: Select all

if (FileExists(CheminRequete + 'Libmysqlclient.18.dylib') )then
 begin
   ShowMessage('Path is ok');
   //I have tried this one
   ConMySQL.LibLocation:=CheminRequete;
  //I have tried this one also
  ConMySQL.LibLocation:=CheminRequete+ 'Libmysqlclient.18.dylib';
   ConMySQL.Connected:=true;
  end
 else
 begin
    ShowMessage('Not there '+CheminRequete);
  end;
EgonHugeist wrote: Check \core\ZPlainLoader.pas
function TZNativeLibraryLoader.ZLoadLibrary(Location: String): Boolean;

how is LoadLibrary on OsX decalred?`I don't know anybody who tested on OsX.
Here is the function. When I check Location it just gives the file name of the library without the path.

Code: Select all

function TZNativeLibraryLoader.ZLoadLibrary(Location: String): Boolean;
var newpath, temp: String; // AB modif
begin
  if FLoaded then
    Self.FreeNativeLibrary;
  temp := ''; //init for FPC
  FLoaded := False;
  Result := False;
  newpath := ExtractFilePath(Location);
  ShowMessage(newpath);
  // AB modif BEGIN
  try
   if newpath <> '' then begin
     temp := GetCurrentDir;
     SetCurrentDir(newpath);
   end;
  // AB modif END

{$IFDEF UNIX}
  {$IFDEF FPC}
    FHandle := LoadLibrary(PAnsiChar(Location));
     ShowMessage(Location);
  {$ELSE}
    FHandle := HMODULE(dlopen(PAnsiChar(Location), RTLD_GLOBAL));
  {$ENDIF}
{$ELSE}
  FHandle := LoadLibrary(PChar(Location));
{$ENDIF}

  // AB modif BEGIN
  finally
   if temp<>'' then
     SetCurrentDir(temp);
  end;
  // AB modif END
  if (FHandle <> INVALID_HANDLE_VALUE) and (FHandle <> 0) then
  begin
    FLoaded := True;
    FCurrentLocation := Location;
    Result := True;
  end;
end; 
So I have forced the Location to be the path of the library like this

Code: Select all

{$IFDEF UNIX}
  {$IFDEF FPC}
   // a very dirty way to force the location
    Location:='/Users/MACBOOK/Documents/CloseAction/Bases/Libmysqlclient.18.dylib';
    FHandle := LoadLibrary(PAnsiChar(Location));
     ShowMessage(Location);
  {$ELSE}
    FHandle := HMODULE(dlopen(PAnsiChar(Location), RTLD_GLOBAL));
  {$ENDIF}
{$ELSE}
  FHandle := LoadLibrary(PChar(Location));
{$ENDIF}  
and it works.
My conclusion for the moment is
  1. The LocationLibrary does not work
  2. The Library names are not good in ZPlainMySQLDriver.pas
The correction of the names is easy but for the bug on the path I don't know
Cratouffe
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 05.10.2014, 14:15

Re: library problem on MAC OSX

Post by Cratouffe »

Hi

I have already posted a long reply to your suggestions but it seems it was lost :( .
So I post it again.
To summarize I have found that the path in the TZConnection.LibraryLocation is not working. I have checked in
function TZNativeLibraryLoader.ZLoadLibrary(Location: String): Boolean;
Location just contains the library file name without the path.
For testing I have added the path like this and it works.

Code: Select all

$IFDEF UNIX}
  {$IFDEF FPC}
    Location:='/Users/MACBOOK/Documents/CloseAction/Bases/Libmysqlclient.18.dylib';
    FHandle := LoadLibrary(PAnsiChar(Location));
     ShowMessage(Location);
  {$ELSE}
    FHandle := HMODULE(dlopen(PAnsiChar(Location), RTLD_GLOBAL));
  {$ENDIF}
{$ELSE}
  FHandle := LoadLibrary(PChar(Location));
{$ENDIF}                      
But I can't do it this way because I am going to distribute my soft.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: library problem on MAC OSX

Post by EgonHugeist »

Cratouffe wrote:My conclusion for the moment is

The LocationLibrary does not work
The Library names are not good in ZPlainMySQLDriver.pas
The LibraryLocation does work. You allready wrote it.
Might be true the Library names are incomplete. Feel free to attach a patch.


Accordingly you issue. I can't see a problem on Zeos side. You simply miss to add you patch to your global OS environment variables OR copy the lib to a path where it simply could be found. Do you really expect Zeos scanns all paths to find one file on your strorage-drive(s)?

You could also generate the path "on the fly" with your enduser app, or locate the library in same path of your executable file... etc...
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Cratouffe
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 05.10.2014, 14:15

Re: library problem on MAC OSX

Post by Cratouffe »

EgonHugeist wrote: The LibraryLocation does work. You allready wrote it.
May be there is a misunderstanding. For me it does not work because when I print ( ShowMessage(Location);) the Location I just have the library name "Libmysqlclient.18.dylib"
and not the full path "'/Users/MACBOOK/Documents/CloseAction/Bases/Libmysqlclient.18.dylib'". And then it is logical that it cant load it.

Code: Select all

{$IFDEF UNIX}
  {$IFDEF FPC}
    FHandle := LoadLibrary(PAnsiChar(Location));
     ShowMessage(Location);
  {$ELSE}
    FHandle := HMODULE(dlopen(PAnsiChar(Location), RTLD_GLOBAL));
  {$ENDIF}
{$ELSE}
  FHandle := LoadLibrary(PChar(Location));
     ShowMessage(Location);
{$ENDIF}
But if I do the same on windows it works. I mean if I put "H:\CloseAction\libmysql.dll" in LibraryLocation it shows "H:\CloseAction\libmysql.dll" in the Location parameter
Did you test the library on a MAC ?
EgonHugeist wrote: Might be true the Library names are incomplete. Feel free to attach a patch.
I did it an now I have the right name.
EgonHugeist wrote: Do you really expect Zeos scanns all paths to find one file on your strorage-drive(s)?
Of course not and that's why there is a LibraryLocation properties
EgonHugeist wrote: You could also generate the path "on the fly" with your enduser app, or locate the library in same path of your executable file... etc...
I have tried to locate it in the same of my executable file but it does not work. But I am not sure of what is the real path of my executable file or if the current directory is my executable file directory.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: library problem on MAC OSX

Post by EgonHugeist »

Before going on:
Which version of Zeos do you use? Could you switch to 7.2-Alpha from SVN to be on same bandwidth?

Are you sure compile-target (e.g. 32 vs. 64 bit) are equal to the library you are trying to load?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Cratouffe
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 05.10.2014, 14:15

Re: library problem on MAC OSX

Post by Cratouffe »

EgonHugeist wrote: Which version of Zeos do you use? Could you switch to 7.2-Alpha from SVN to be on same bandwidth?
I am using 7.1.3 version. I have downloaded th 7.2 beta (I have not found the alpha) and I will switch as soon as possible
EgonHugeist wrote: Are you sure compile-target (e.g. 32 vs. 64 bit) are equal to the library you are trying to load?
I am in 32 bit.
Cratouffe
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 05.10.2014, 14:15

Re: library problem on MAC OSX

Post by Cratouffe »

It seems that the 7.2 version has solved the problem. :D
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: library problem on MAC OSX

Post by EgonHugeist »

Sure?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Cratouffe
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 05.10.2014, 14:15

Re: library problem on MAC OSX

Post by Cratouffe »

For my first simple application it works. But for a more heavy application it seems there is some more problems but I am not sure they are ZeosLib's problems.
I keep going on and many thanks for your help
Post Reply