Development environment:
macos Ventura 13.2.1
lazarus 2.2.4
indylaz 10.6.2.4089
Simple library demo test:
library project1;
{$mode Delphi}{$H+}
{$IFDEF MSWINDOWS}
{$calling stdcall}
{$ENDIF}
{$IFDEF Unix}
{$calling cdecl}
{$ENDIF}
{$IFDEF Darwin}
{$calling cdecl}
{$ENDIF}
{$R *.res}
uses
interfaces, Classes, indylaz;
function substr(CString: PChar; FromPos, ToPos: Longint): PChar;
var
Length: Integer;
begin
Length := StrLen(CString);
SubStr := CString + Length;
if (FromPos > 0) and (ToPos >= FromPos) then
begin
if Length >= FromPos then
SubStr := CString + FromPos;
if Length > ToPos then
CString[ToPos+1] := #0;
end;
end;
exports
substr;
end.
Simple program for test:
unit Unit1;
{$mode objfpc}{$H+}
{$IFDEF MSWINDOWS}
{$calling stdcall}
{$ENDIF}
{$IFDEF Unix}
{$calling cdecl}
{$ENDIF}
{$IFDEF Darwin}
{$calling cdecl}
{$ENDIF}
{$LinkLib project1}
interface
uses
dynlibs, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button2: TButton;
Memo1: TMemo;
procedure Button2Click(Sender: TObject);
private
apri : procedure;
public
end;
var
Form1: TForm1;
function substr(CString: PChar; FromPos, ToPos: Longint): PChar; cdecl; external;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button2Click(Sender: TObject);
var
a : array [0..100] of char;
path : string;
begin
a := 'ciao a tutti';
Memo1.Lines.Add(substr(a, 2, 4));
end;
end.
With dependency on indylaz, it exits with errors:
./testlib_lazarus
objc[1664]: Class TCocoaTimerObject is implemented in both /Users/ugoboccardi/lazarus/test library/libproject1.dylib (0x107889640) and /Users/ugoboccardi/lazarus/test library/testlib_lazarus (0x10566d738). One of the two will be used. Which one is undefined.
objc[1664]: Class TAppDelegate is implemented in both /Users/ugoboccardi/lazarus/test library/libproject1.dylib (0x107889690) and /Users/ugoboccardi/lazarus/test library/testlib_lazarus (0x10566d788). One of the two will be used. Which one is undefined.
objc[1664]: Class TCocoaApplication is implemented in both /Users/ugoboccardi/lazarus/test library/libproject1.dylib (0x1078896e0) and /Users/ugoboccardi/lazarus/test library/testlib_lazarus (0x10566d7d8). One of the two will be used. Which one is undefined.
objc[1664]: Class TLCLEventMessage is implemented in both /Users/ugoboccardi/lazarus/test library/libproject1.dylib (0x107889730) and /Users/ugoboccardi/lazarus/test library/testlib_lazarus (0x10566d828). One of the two will be used. Which one is undefined.
objc[1664]: Class TCocoaAlertCancelAccessoryView is implemented in both /Users/ugoboccardi/lazarus/test library/libproject1.dylib (0x107889780) and /Users/ugoboccardi/lazarus/test library/testlib_lazarus (0x10566d878). One of the two will be used. Which one is undefined.
...
[FORMS.PP] ExceptionOccurred
Sender=EStackOverflow
Exception=Stack overflow
Stack trace:
$00000001070D69E0
Exception at 00000001070D69E0: EStackOverflow:
Stack overflow.
Without inserting the dependency on indylaz in the library, it works.
The same code in Lazarus on Windows or Linux works perfectly.
Does anyone have any idea what can be done?