Forum > macOS / Mac OS X

dynamic library not load when you add indylaz requirement (in library)

(1/1)

uganof:
Development environment:

macos Ventura 13.2.1
lazarus 2.2.4
indylaz 10.6.2.4089

Simple library demo test:


--- Code: ---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.     

--- End code ---

Simple program for test:


--- Code: ---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.   

--- End code ---

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?

KodeZwerg:
Welcome to forum!
Please use the [ # ] button and put your code within the [ code ] your code [ /code ] tags.

My belly tells me, here you have an error.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function substr(CString: PChar; FromPos, ToPos: Longint): PChar; cdecl; external;Should be

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function substr(CString: PChar; FromPos, ToPos: Longint): PChar; external;

uganof:

--- Quote ---Welcome to forum!
--- End quote ---

thanks!


--- Quote ---Please use the [ # ] button and put your code within the [ code ] your code [ /code ] tags.
--- End quote ---

now it is more beautiful  :D


--- Quote ---My belly tells me, here you have an error.
--- End quote ---

unfortunately that's not the problem, cdecl is normal on linux or macos. Rather, it appears that the indylaz package links to a library it shouldn't

uganof:
I dug deeper and realized that the problem is in the initialization section of the indy library, cocoa class duplication messages have nothing to do with it.

In the source I eliminated the indylaz unit and put the idglobal to make troubleshooting easier


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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, IdGlobal; 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.    
The result was the same, with the same errors.

But, if in IdGlobal I delete the intialization section all works!

it is not a problem of the initialization section because I use it in other libraries and it works correctly but something seems to be activated in the Indy library which makes it unusable.

Does anyone have an idea what it could be?

Navigation

[0] Message Index

Go to full version