Recent

Author Topic: MediaInfoLib wrapper for Lazarus on MacOS  (Read 1218 times)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 883
MediaInfoLib wrapper for Lazarus on MacOS
« on: December 01, 2020, 11:31:34 am »
hello,
i have converted the mediaInfoLib wrapper for delphi to Lazarus, so that it would be possible to use it on Linux and MacOs. MediaInfo is a free, cross-platform and open-source program that displays technical information about media files, as well as tag information for many audio and video files. It is used in many programs such as XMedia Recode, MediaCoder, eMule, and K-Lite Codec Pack. The wrapper is OK on windows 10 and Centos 8.1 with Lazarus 2.0.10 and fpc 3.2. But i haven't Mac and i can't test the wrapper on it. If someone can test the demo project coming with the wrapper on Mac, it would be so nice.
The wrapper unit and the demo project are here.



Friendly J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1204
  • Former Delphi 1-7, 10.2 User
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #1 on: December 02, 2020, 12:17:15 am »
OK - luckily I had $1 left in the app store and so I paid the required 99c for a copy of MediaInfo for macOS.

I needed to change the code to this for it to load the library successfully:

Code: Pascal  [Select][+][-]
  1. {$ELSEIF defined(DARWIN)}
  2.     if (MediaInfoDLL_Load('/Applications/MediaInfo.app/Contents/Resources/libmediainfo.dylib')=false) then
  3.   begin
  4.       Memo1.Text := 'Error while loading libmediainfo.dylib';
  5.       exit;
  6.   end;

Note both the name is different from your original code and that the path must be specified because the library is in the resources folder of the Mediainfo application bundle. If creating an app using the wrapper you would normally include the library in the Resources folder of the application bundle and therefore need ti adjust the path accordingly (refer to the Wiki article  Locating the macOS application resources directory for code to do this).

So now clicking the button opens a dialog and I can choose an audio file, but no matter what file I choose I get a dialog with an access violation and the option to Abort or continue and risk corrupting the universe :(

Also note: the project did not work (Error while loading ibmediainfo.dylib) when compiled and run on the M1 Apple Silicon processor Mac mini. I suspect the issue is trying to load/execute an Intel library from a native Apple Silicon (ARM64) application. The MediaInfo application, an Intel binary, does work running under Apple's Rosetta2 Intel emulation on the M1 Mac mini.
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 883
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #2 on: December 02, 2020, 01:08:27 am »
hello,
thanks Trev for your contribution and sorry to have to pay for mediainfo  :(
Found this in the python wrapper for MacOS (darwin) :
Code: Python  [Select][+][-]
  1.  
  2.           if library_file is None:
  3.             if os_is_nt:
  4.                 library_names = ("MediaInfo.dll",)
  5.             elif sys.platform == "darwin":
  6.                 library_names = ("libmediainfo.0.dylib", "libmediainfo.dylib")
  7.             else:
  8.                 library_names = ("libmediainfo.so.0",)
  9.             script_dir = os.path.dirname(__file__)
  10.             # Look for the library file in the script folder
  11.             for library in library_names:
  12.                 lib_path = os.path.join(script_dir, library)
  13.                 if os.path.isfile(lib_path):
  14.                     # If we find it, don't try any other filename
  15.                     library_names = (lib_path,)
  16.                     break

Do you think i must remove MacOS from the O.S targets of the wrapper for the moment because it isn't stable ?

Friendly, J.P
« Last Edit: December 02, 2020, 01:29:45 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1204
  • Former Delphi 1-7, 10.2 User
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #3 on: December 02, 2020, 01:44:13 am »
I need to work out what's causing the access violation... later today, the time Gods willing.
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 883
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #4 on: December 02, 2020, 02:11:44 am »
I need to work out what's causing the access violation
i have seen in the python wrapper that the functions are called with cdecl  for linux and darwin
Code: Python  [Select][+][-]
  1.         os_is_nt = os.name in ("nt", "dos", "os2", "ce")
  2.         if os_is_nt:
  3.             lib_type = ctypes.WinDLL  # type: ignore
  4.         else:
  5.             lib_type = ctypes.CDLL
  6.  



 Try this in the file  MediaInfoDll.pas
Code: Pascal  [Select][+][-]
  1. var
  2.   LibHandle: THandle = 0;
  3.  
  4.  {$IFDEF WINDOWS}
  5.   // Unicode methods
  6.   MediaInfo_New:        function  (): THandle stdcall;
  7.   MediaInfo_Delete:     procedure (Handle: THandle) stdcall;
  8.   MediaInfo_Open:       function  (Handle: THandle; File__: PWideChar): Cardinal  stdcall;
  9.   MediaInfo_Close:      procedure (Handle: THandle)  stdcall;
  10.   MediaInfo_Inform:     function  (Handle: THandle; Reserved: Integer): PWideChar  stdcall;
  11.   MediaInfo_GetI:       function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer;   KindOfInfo: TMIInfo): PWideChar  stdcall; //Default: KindOfInfo=Info_Text,
  12.   MediaInfo_Get:        function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PWideChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PWideChar  stdcall; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name
  13.   MediaInfo_Option:     function  (Handle: THandle; Option: PWideChar; Value: PWideChar): PWideChar stdcall;
  14.   MediaInfo_State_Get:  function  (Handle: THandle): Integer stdcall;
  15.   MediaInfo_Count_Get:  function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer stdcall;
  16.     // Ansi methods
  17.   MediaInfoA_New:       function  (): THandle  stdcall;
  18.   MediaInfoA_Delete:    procedure (Handle: THandle) stdcall;
  19.   MediaInfoA_Open:      function  (Handle: THandle; File__: PAnsiChar): Cardinal stdcall;
  20.   MediaInfoA_Close:     procedure (Handle: THandle)  stdcall;
  21.   MediaInfoA_Inform:    function  (Handle: THandle; Reserved: Integer): PAnsiChar  stdcall;
  22.   MediaInfoA_GetI:      function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PAnsiChar  stdcall; //Default: KindOfInfo=Info_Text
  23.   MediaInfoA_Get:       function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PAnsiChar;   KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PAnsiChar  stdcall; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name
  24.   MediaInfoA_Option:    function  (Handle: THandle; Option: PAnsiChar; Value: PAnsiChar): PAnsiChar  stdcall;
  25.   MediaInfoA_State_Get: function  (Handle: THandle): Integer stdcall;
  26.   MediaInfoA_Count_Get: function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer  stdcall;
  27.  
  28.   {$ELSE}
  29.   MediaInfo_New:       function  (): THandle  cdecl;
  30.   MediaInfo_Delete:    procedure (Handle: THandle) cdecl;
  31.   MediaInfo_Open:      function  (Handle: THandle; File__: PAnsiChar): Cardinal cdecl;
  32.   MediaInfo_Close:     procedure (Handle: THandle)  cdecl;
  33.   MediaInfo_Inform:    function  (Handle: THandle; Reserved: Integer): PAnsiChar  cdecl;
  34.   MediaInfo_GetI:      function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PAnsiChar  cdecl; //Default: KindOfInfo=Info_Text
  35.   MediaInfo_Get:       function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PAnsiChar;   KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PAnsiChar  cdecl; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name
  36.   MediaInfo_Option:    function  (Handle: THandle; Option: PAnsiChar; Value: PAnsiChar): PAnsiChar  cdecl;
  37.   MediaInfo_State_Get: function  (Handle: THandle): Integer cdecl;
  38.   MediaInfo_Count_Get: function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer  cdecl;
  39.     // Ansi methods
  40.   MediaInfoA_New:       function  (): THandle  cdecl;
  41.   MediaInfoA_Delete:    procedure (Handle: THandle) cdecl;
  42.   MediaInfoA_Open:      function  (Handle: THandle; File__: PAnsiChar): Cardinal cdecl;
  43.   MediaInfoA_Close:     procedure (Handle: THandle)  cdecl;
  44.   MediaInfoA_Inform:    function  (Handle: THandle; Reserved: Integer): PAnsiChar  cdecl;
  45.   MediaInfoA_GetI:      function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PAnsiChar  cdecl; //Default: KindOfInfo=Info_Text
  46.   MediaInfoA_Get:       function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PAnsiChar;   KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PAnsiChar  cdecl; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name
  47.   MediaInfoA_Option:    function  (Handle: THandle; Option: PAnsiChar; Value: PAnsiChar): PAnsiChar  cdecl;
  48.   MediaInfoA_State_Get: function  (Handle: THandle): Integer cdecl;
  49.   MediaInfoA_Count_Get: function  (Handle: THandle; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer  cdecl;
  50.   {$ENDIF}    
  51.  

it works for me on Centos.
« Last Edit: December 02, 2020, 02:27:50 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1204
  • Former Delphi 1-7, 10.2 User
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #5 on: December 02, 2020, 02:42:05 am »
Both version generate an access violation in the same place (in the library?).

See attached pics.
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 883
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #6 on: December 04, 2020, 09:16:58 am »
hello,
Both version generate an access violation in the same place (in the library?).
Finally, i could tested the wrapper on MAC OS 10.15.7  (catalina) with lazarus 2.0.10  fpc 3.2
the access violation was caused by HandleMI = Cardinal   -> 32 bits : not use a Cardinal for a Handle.
Cardinal replaced by PtrUint

Quote
// MAC Darwin -> libmediainfo.0.dylib tested on MacOs 10.15.7 (Catalina) Lazarus 2.0.10 fpc 3.2
For MAC do not use AppleStore to get Mediainfo (you must pay)
Download the dylib from here : https://mediaarea.net/fr/MediaInfo/Download/Mac_OS
Extract the file libmediainfo.0.dylib and put it for example in $HOME/lib (create lib if not exist)

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1204
  • Former Delphi 1-7, 10.2 User
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #7 on: December 04, 2020, 11:07:03 am »
Yay, both dylibs (paid & free) work :)
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 883
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #8 on: December 06, 2020, 08:45:18 am »
hello,
i have a problem with filename with non ascii characters  (ex: Example héhé.ogg)  on Mac OS. the Open Function doesn't work (return 0).
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1204
  • Former Delphi 1-7, 10.2 User
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #9 on: December 06, 2020, 10:48:37 am »
Weird - it works for me. See attached pic.
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1204
  • Former Delphi 1-7, 10.2 User
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #10 on: December 06, 2020, 11:04:36 am »
Updated for macOS - location of the library in the app bundle:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4. {$IFDEF DARWIN}
  5. {$modeswitch objectivec1}
  6. {$ENDIF}
  7.  
  8. interface
  9.  
  10. uses
  11.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  12.   Variants, MediaInfoDll,
  13.   {$IFDEF DARWIN}
  14.   CocoaAll,   // Needed for NSBundle
  15.   CocoaUtils  // Needed for NSStringToString
  16.   {$ENDIF}
  17.   ;
  18.  
  19. type
  20.  
  21.   { TForm1 }
  22.  
  23.   TForm1 = class(TForm)
  24.     Button1: TButton;
  25.     Memo1: TMemo;
  26.     OpenDialog1: TOpenDialog;
  27.     procedure Button1Click(Sender: TObject);
  28.   private
  29.  
  30.   public
  31.  
  32.   end;
  33.  
  34. var
  35.   Form1: TForm1;
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41. { TForm1 }
  42.  
  43. procedure TForm1.Button1Click(Sender: TObject);
  44. var
  45.   HandleMI: PtrUint; //Cardinal;
  46.   {$IFDEF WINDOWS}
  47.   To_Display: WideString;
  48.   CR: WideString;
  49.   filename: Widestring;
  50.   {$ELSE}
  51.   To_Display: String;
  52.   CR: String;
  53.   filename: String;
  54.   {$ENDIF}
  55.  
  56. begin
  57.   CR:=Chr(13) + Chr(10);
  58.   {$IF  defined(WINDOWS)}
  59.   if (MediaInfoDLL_Load('mediainfo.dll')=false) then
  60.   begin
  61.       Memo1.Text := 'Error while loading mediainfo.dll';
  62.       exit;
  63.   end;
  64.   {$ELSEIF defined(DARWIN)}
  65.   //if (MediaInfoDLL_Load('/Applications/MediaInfo.app/Contents/Resources/libmediainfo.dylib')=false) then
  66.   if (MediaInfoDLL_Load(NSStringToString(NSBundle.mainBundle.resourcePath) + PathDelim + 'libmediainfo.dylib')=false) then
  67.   begin
  68.       Memo1.Text := 'Error while loading libmediainfo.dylib';
  69.       exit;
  70.   end;
  71.   {$ELSE }     // Linux
  72.   if (MediaInfoDLL_Load('libmediainfo.so.0')=false) then
  73.   begin
  74.       Memo1.Text := 'Error while loading libmediainfo.so.0';
  75.       exit;
  76.   end;
  77.   {$ENDIF}
  78.   To_Display := MediaInfo_Option (0, 'Info_Version', '') + CR;
  79.   if OpenDialog1.Execute then
  80.     begin
  81.       filename := OpenDialog1.Filename;
  82.  
  83.       HandleMI := MediaInfo_New();
  84.       To_Display := To_Display + 'Open' + CR;
  85.       {$IFDEF WINDOWS}
  86.       To_Display := To_Display + format('%d', [MediaInfo_Open(HandleMI, PWideChar(filename))]);
  87.       {$ELSE}
  88.        To_Display := To_Display + format('%d', [MediaInfo_Open(HandleMI, PChar(filename))]);
  89.       {$ENDIF}
  90.  
  91.       To_Display := To_Display + CR + CR + 'Inform with Complete=false' + CR;
  92.       MediaInfo_Option (HandleMI, 'Complete', '');
  93.       To_Display := To_Display + MediaInfo_Inform(HandleMI, 0);
  94.  
  95.       To_Display := To_Display + CR + CR + 'Inform with Complete=true' + CR;
  96.       MediaInfo_Option (HandleMI, 'Complete', '1');
  97.       To_Display := To_Display + MediaInfo_Inform(HandleMI, 0);
  98.  
  99.       To_Display := To_Display + CR + CR + 'Custom Inform' + CR;
  100.       MediaInfo_Option (HandleMI, 'Inform', 'General;Example : FileSize=%FileSize%');
  101.       To_Display := To_Display + MediaInfo_Inform(HandleMI, 0);
  102.       MediaInfo_Option (HandleMI, 'Inform', '');
  103.       //To_Display := To_Display + CR + CR + 'GetI with Stream=General and Parameter:=17' + CR;
  104.       //To_Display := To_Display + MediaInfo_GetI(HandleMI, Stream_General, 0, 17, Info_Text);
  105.       //
  106.       //To_Display := To_Display + CR + CR + 'Count_Get with StreamKind=Stream_Audio' + CR;
  107.       //To_Display := To_Display + format('%d', [MediaInfo_Count_Get(HandleMI, Stream_Audio, -1)]);
  108.       //
  109.       //To_Display := To_Display + CR + CR + 'Get with Stream:=General and Parameter=^AudioCount^' + CR;
  110.       //To_Display := To_Display + MediaInfo_Get(HandleMI, Stream_General, 0, 'AudioCount', Info_Text, Info_Name);
  111.       //
  112.       //To_Display := To_Display + CR + CR + 'Get with Stream:=Audio and Parameter=^StreamCount^' + CR;
  113.       //To_Display := To_Display + MediaInfo_Get(HandleMI, Stream_Audio, 0, 'StreamCount', Info_Text, Info_Name);
  114.       //
  115.       To_Display := To_Display + CR + CR + 'Get with Stream:=General and Parameter=^FileSize^' + CR;
  116.       To_Display := To_Display + MediaInfo_Get(HandleMI, Stream_General, 0, 'FileSize', Info_Text, Info_Name);
  117.  
  118.       To_Display := To_Display + CR + CR + 'Close' + CR;
  119.       MediaInfo_Close(HandleMI);
  120.       MediaInfo_Delete(HandleMI);
  121.       Memo1.Text := To_Display;
  122.  
  123.     end;
  124.  
  125.  
  126. end;
  127.  
  128. end.
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 883
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #11 on: December 06, 2020, 11:12:26 am »
thanks for the test trev   
i have  always the problem. Environment problem? Version of MacOS ? lazarus, fpc version ? (me 2.0.10 - 3.2)  (see attachments)
And for the path of the dynamic library if i put the file libmediainfo.0.dylib in the folder /Users/<user>/lib
Code: Pascal  [Select][+][-]
  1. {$ELSEIF defined(DARWIN)}
  2.   if (MediaInfoDLL_Load('libmediainfo.0.dylib')=false) then
  3.   begin
  4.       Memo1.Text := 'Error while loading libmediainfo.0.dylib';
  5.       exit;
  6.   end;

works for me


« Last Edit: December 06, 2020, 01:25:44 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1204
  • Former Delphi 1-7, 10.2 User
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #12 on: December 07, 2020, 01:39:58 am »
thanks for the test trev   
i have  always the problem. Environment problem? Version of MacOS ? lazarus, fpc version ? (me 2.0.10 - 3.2)  (see attachments)

Code: Text  [Select][+][-]
  1. trev@macmini7 [/Users/trev] $ printenv
  2. LANG=en_AU.UTF-8
  3. USER=trev
  4. LOGNAME=trev
  5. HOME=/Users/trev
  6. PATH=/Users/trev/bin:/Users/trev/GreatCowBasic:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/VMware:Fusion.app/Contents/Public:/opt/X11/bin
  7. MAIL=/var/mail/trev
  8. SHELL=/bin/tcsh
  9. TERM=xterm-256color
  10. SSH_CLIENT=192.168.1.21 50052 22
  11. SSH_CONNECTION=192.168.1.21 50052 192.168.1.20 22
  12. SSH_TTY=/dev/ttys000
  13. TMPDIR=/var/folders/t3/f0rslzrn70qb61l12j31c5sr0000gn/T/
  14. HOSTTYPE=unknown
  15. VENDOR=apple
  16. OSTYPE=darwin
  17. MACHTYPE=x86_64
  18. SHLVL=1
  19. PWD=/Users/trev
  20. GROUP=staff
  21. HOST=macmini7.sentry.org
  22. REMOTEHOST=192.168.1.21
  23. EDITOR=vi
  24. EXINIT=set autoindent
  25. PAGER=more
  26. BLOCKSIZE=K
  27. PRINTER=xerox
  28. FTP_PASSIVE_MODE=NO
  29. FTP_TIMEOUT=300
  30. PAPERSIZE=A4

Quote
And for the path of the dynamic library if i put the file libmediainfo.0.dylib in the folder /Users/<user>/lib
Code: Pascal  [Select][+][-]
  1. {$ELSEIF defined(DARWIN)}
  2.   if (MediaInfoDLL_Load('libmediainfo.0.dylib')=false) then
  3.   begin
  4.       Memo1.Text := 'Error while loading libmediainfo.0.dylib';
  5.       exit;
  6.   end;

works for me

Yep, but this is not the correct way under macOS. Libraries should be included in the Resources directory of the application bundle. If nothing else than complying with the Apple macOS paradigm , it allows for easy drag and drop installation from a disk image (.dmg) and easy uninstall (dragging the application to the bin [au] / trash [us]).
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 883
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #13 on: December 07, 2020, 08:12:01 am »
hello,
When i launch the executable from project folder, it works : Media file with non ascii characters works.
When i launch it from Lazarus it doesn't work (open return 0).
When i launch it from Lazarus without debugging -> error unable to run project1.app.
I am a rookie on MAC and may be i do something wrong or i have a wrong setting in Lazarus.
Another question :
How do you put  the dylib file   in the Resources directory of the application bundl? With the File Explorer ?
On Mac always create an application bundle  ?

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1204
  • Former Delphi 1-7, 10.2 User
Re: MediaInfoLib wrapper for Lazarus on MacOS
« Reply #14 on: December 07, 2020, 08:38:04 am »
When i launch the executable from project folder, it works : Media file with non ascii characters works.
When i launch it from Lazarus it doesn't work (open return 0).

It works for me in both run with debugging and run w/o debugging from within Lazarus.

Quote
When i launch it from Lazarus without debugging -> error unable to run project1.app.

This one is a Lazarus bug which I logged and has been resolved in trunk (what I'm using).

Quote
How do you put  the dylib file   in the Resources directory of the application bundl? With the File Explorer ?

Yes. You only need to do it once, unless you recreate the application bundle.

Quote
On Mac always create an application bundle  ?

For GUI applications, yes.

You can find much useful macOS info in the Wiki's Mac Portal.
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

 

TinyPortal © 2005-2018