macOS app with mySQL or Mariadb lazarus / 16-Databases ---------------------------------------------------------------------- Tomki · 2023-06-17 20:00 I try to develop an app that connects to a Mariadb server, but I‘m stuck as far as portabilty (I mean use the app on another Mac) is concerned. I‘m obviously not able to bundle necessary libraries in an macOS app bundle. Did anyone build a macOS app with mysql and a correspomding application bundle? Can anyone tell me what to do to make the app connect to a mysql (or mariadb server) when used on a Mac where mySQL sever is not installed? I‘m desperately looking for a solution. Thanks in advance for help! ---------------------------------------------------------------------- madref · 2023-06-18 22:42 I don't think that it makes any difference. It's all about how to get the data from the database In Lazarus it's almost the same ---------------------------------------------------------------------- Tomki · 2023-06-19 11:54 In any case, there is a huge difference between windows and macOS. The use of dll in windows is no problem - also not the use on another windows system.  Under macos I despair of using dylib, which I need for the mysql client. The simple reference to a library is useless under macos, because you have to use install_name_tool etc. and executable_path and so on, if you want to integrate it into a macOS app bundle. I just can't get that to work! Although I think I followed the steps that needed to be done. If someone could explain those steps, I would be grateful. Rgds Thomas ---------------------------------------------------------------------- madref · 2023-06-26 10:47 If you all put in your app's bundle then addressing it is easy. You know where it is partly. Now you only have to get your app's directory 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 ProgramDir := LeftStr (ExtractFilePath(Application.ExeName), Length(ExtractFilePath(Application.ExeName))-15);ResourceDir := ProgramDir + 'Contents/Resources/'; And now it doesn't matter where you put your app-bundle on your drive... it just works ---------------------------------------------------------------------- Tomki · 2023-06-29 08:22 Thanks MadRef I'll try that one. However the information about using install_name_tool is very confusing to me. Everybody, but you  referred to using this tool for the libraries in a MacOS bundle. If it works your way - that would be great ---------------------------------------------------------------------- madref · 2023-07-01 19:06 and does it work....Quote from: Tomki on June 29, 2023, 10:22:29 amThanks MadRef I'll try that one. However the information about using install_name_tool is very confusing to me. Everybody, but you  referred to using this tool for the libraries in a MacOS bundle. If it works your way - that would be great ---------------------------------------------------------------------- eldonfsr · 2023-07-10 15:52 Well sorry for my english i try to explain my experience with lazarus on mac... first don't to change location of dydll for mysql that is locate on '/usr/local/myql/lib/mysqlclient.dylib'  keep this on same location... and tell that in your app here a sample how i do that.. 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    {$IFDEF WINDOWS}       SQLDBLLib.LibraryName:=WideString(ExtractFilePath(ParamStr(0)) + 'libmysql.dll');       FormMain.PathFile:= Application.Location;       FormMain.UserFolder:= GetUserDir+'Documents';       if( not DirectoryExists(FormMain.UserFolder+'/opticas')) then begin        If Not CreateDir (FormMain.UserFolder+'/opticas') Then begin            ShowMessage('No puedo crear el directorio para opticas en documentos !');            Application.Terminate;        end;       end;       FormMain.CurrFolder:=FormMain.PathFile;       Formmain.HomeFolder:=FormMain.PathFile;       SQLDBLLib.LoadLibrary;       AbrirBasesdeDatos(Sender);     {$ENDIF} {$IFDEF DARWIN}       SQLDBLLib.LibraryName:='/usr/local/mysql/lib/libmysqlclient.dylib';     FormMain.PathFile:= Application.Location;       Fstr:= Copy(FormMain.PathFile,0,Pos('.app', FormMain.PathFile));       FormMain.HomeFolder:= Copy(FStr,0,RPos('/',FStr));       FormMain.UserFolder:= '/Users/'+GetEnvironmentVariable('USER')+'/Documents/';       if( not DirectoryExists(FormMain.UserFolder+'opticas')) then begin          If Not CreateDir (Formmain.UserFolder+'opticas') Then begin             ShowMessage('No Pudo crear el directorio en el folder del usurio para guardar documentos');             Application.Terminate;          end;       end;       if( FileExists('/usr/local/mysql/lib/libmysqlclient.dylib')) then begin         SQLDBLLib.LibraryName:='/usr/local/mysql/lib/libmysqlclient.dylib';     end else begin           ShowMessage('La Liberia de mysql no existe cheque que este en '+'/usr/local/mysql/lib/libmysqlclient.dylib');           Application.Terminate;//           SQLDBLLib.LibraryName:=FormMain.HomeFolder+'libmysqlclient.dylib';     end;       FormMain.CurrFolder:=FormMain.PathFile;       SQLDBLLib.LoadLibrary;       AbrirBasesdeDatos(Sender);     {$ENDIF} procedure TDM.AbrirBasesdeDatos(Sender:Tobject);Var dbexist,newschema:Boolean;    Query:TsqlQuery;begin  dbexist:=false;  newschema:=false;  Query:=TSqlQuery.create(nil);  Query.DataBase := MySqlcOpti;  Query.Transaction := SQLTopti;  try  if FileExists(WideString(FormMain.HomeFolder + 'settings.dat') ) then begin     FormMain.MDSetup.LoadFromFile(FormMain.HomeFolder + 'settings.dat');     FormMain.MDSetup.Open;     MySQLCOpti.Connected:=false;     MySQLCOpti.HostName:=FormMain.MDSetu p.FieldByName('IpServer').AsString;     MySQLCOpti.UserName:=FormMain. MDSetup.FieldByName('Usuario').AsString;     MySQLCOpti.Password:=Form Main.MDSetup.FieldByName('password').AsString;     MySQLCOpti.Database Name:=FormMain.MDSetup.FieldByName('database').AsString;     MySQLCOpti.Connected:=true;  end  else begin     If not Assigned(FormSetup) then begin        Application.CreateForm(TFormSetup, FormSetup);     end;     FormSetup.ShowModal;  end;  except    on E: EDatabaseError do      ShowMessage( 'Database error: '+ E.ClassName + #13#10 + E.Message );  on E: Exception do begin       MessageDlg('Ocurrio un error al connectarse a la base de datos de opticas'+E.Message,         mtError, [mbOK], 0);       Application.Terminate;     end;    end;  only on windows can change the location of dll to your app folder... i installed mysql with homebrew after config mysql to setup user and password. of course is how i made could be no best option but for my is working like that...