library (.so) cannot GetProcAddress lazarus / 21-General ---------------------------------------------------------------------- metallaro1980 · 2021-01-03 11:03 I made a library that creates star maps. this is the general form in the library project 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 function Ma inMappa(latitude:extended;extended:extended;year:integer;month:integer ;day:integer;hour:integer;min:integer;sec:integer):boolean; cdecl; exports MainMappa; but in another simply project i cannot run the function 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 unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, dynlibs; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);   private  public  end; var  Form1: TForm1; implementation {$R *.lfm} type  Tbool = function (latitude:ext ended;extended:real;year:integer;month:integer;day:integer;hour:intege r;min:integer;sec:integer):boolean;cdecl; { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin end; procedure TForm1.Button1Click(Sender:TObject);var mHandle : TLibHandle;var Compute:Tbool;begin  mHandle:=LoadLibrary('libmappestellari.so');  if mHandle<>0 then  begin    Compute:=Tbool(GetProcAddress(mHandle,'MainMappa'));     if Assigned(Compute) then      Compute(44.8621664, 10.0530928, 2021, 1, 3, 22, 0, 0);     FreeLibrary(mHandle);  end  else    ShowMessage('Library not found');end; end. it does not find the GetProcAddress any hints? any helps? thank you very much [Edited to add code tags - please use them - How to use the Forums.] ---------------------------------------------------------------------- cdbc · 2021-01-03 11:49 Hi Try this: 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 type    TMainMappa = function (latitude:extended;extended:extended;year:intege r;month:integer;day:integer;hour:integer;min:integer;sec:integer):bool ean;cdecl;.....procedure TForm1.Button1Click(Sender:TObject);var   mHandle: TLibHandle;   Compute: TMainMappa;  Res: boolean;begin  mHandle:= LoadLibrary('libmappestellari.so');  if mHandle<>0 then    begin      Compute:= nil; // for the check with "assigned()"      Compute:= TMainMappa(GetProcAddress(mHandle,'MainMappa'));      if Assigned(Compute) then        Res:= Compute(44.8621664, 10.0530928, 2021, 1, 3, 22, 0, 0);      Compute:= nil; // release the link      FreeLibrary(mHandle);    end else ShowMessage('Library not found');end; Your function signature must match exactly that in the library! HTH Regards Benny ---------------------------------------------------------------------- metallaro1980 · 2021-01-03 12:25 Quote from: cdbc on January 03, 2021, 12:49:54 pmHi Try this: 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 type    TMainMappa = function (latitude:extended;extended:extended;year:intege r;month:integer;day:integer;hour:integer;min:integer;sec:integer):bool ean;cdecl;.....procedure TForm1.Button1Click(Sender:TObject);var   mHandle: TLibHandle;   Compute: TMainMappa;  Res: boolean;begin  mHandle:= LoadLibrary('libmappestellari.so');  if mHandle<>0 then    begin      Compute:= nil; // for the check with "assigned()"      Compute:= TMainMappa(GetProcAddress(mHandle,'MainMappa'));      if Assigned(Compute) then        Res:= Compute(44.8621664, 10.0530928, 2021, 1, 3, 22, 0, 0);      Compute:= nil; // release the link      FreeLibrary(mHandle);    end else ShowMessage('Library not found');end; Your function signature must match exactly that in the library! HTH Regards Benny The signature is correct. now it attempts to execute the Compute but I get SIGSEGV error ! ---------------------------------------------------------------------- jamie · 2021-01-03 14:35 maybe the compiler is generating wrong code because you have a "extended:Extended" in there ? ---------------------------------------------------------------------- metallaro1980 · 2021-01-03 14:42 Quote from: jamie on January 03, 2021, 03:35:50 pmmaybe the compiler is generating wrong code because you have a "extended:Extended" in there ? i fixed with latitude:extended;longitude:extended;... i still have same problems ---------------------------------------------------------------------- jamie · 2021-01-03 14:56 are we so sure its extended and not double ? ---------------------------------------------------------------------- cdbc · 2021-01-04 12:31 Hi Hmmmm, try changing the function result to bool instead of boolean... or return an integer, Result = 0 ~ false, Result = anything but 0 ~ true. You are working with a C interface, and with an integer Result you get a lot more possibilities. 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 const  libFalse = 0;  libTrue  = 1;  libOK    = 2;  libError = 3;.....Implement:   "function GetLastError: integer; cdecl;"  "function GetLasterrorDescription(anError: integer): pchar; cdecl;"  "procedure ClearLastError; cdecl;"In your library.And remember, the memory you allocate in library must be freed in library! HTH Regards Benny ---------------------------------------------------------------------- cdbc · 2021-01-04 14:58 Hi ...Right, so i took what code you showed me and started up my trusty Lazarus+Fpc :-) Compiled both projects. Put the library in "/usr/lib64/" and ran the test app and .... wait for it ... "It Flies Like An Eagle" :-D (couldn't help myself). Right, back to business, so I can conclude: 1) boolean results work over library boundries. 2) your code to use the library works (in my version). 3) the origin of your sigsev is in the function in library!!! Have a closer look at your library code "MainMappa". I've attached the test project. HTH Regards Benny ---------------------------------------------------------------------- metallaro1980 · 2021-01-04 15:18 i copy the function MainMappa and just what the function needs (the same of the library) in a new project (executable not library) and it works! i can't find where the problem is in the function I also did this program in c ++ but I can't find libs for handling bitmaps with lines, arcs, circles and fills ---------------------------------------------------------------------- cdbc · 2021-01-04 15:43 Hi 1) try getting in contact with Circular, he makes BGRABitmap toolkit, maybe he can help... 2) Would you mind sharing the MainMappa code with us, otherwise we can't really help you? Regards Benny ---------------------------------------------------------------------- metallaro1980 · 2021-01-04 15:48 enjoy it ! it is full of astronomical calculations ---------------------------------------------------------------------- cdbc · 2021-01-04 15:51 Hi Will do, hangon for a bit  Regards Benny