DLL issue lazarus / 13-General ---------------------------------------------------------------------- Tommi · 2008-12-02 13:18 I'm soing some experiment about dlls with this code: Code: [Select] library project1; uses   Classes   { you can add units after this }; function SubStr(CString: PChar;FromPos,ToPos: Longint): PChar; cdecl; export; 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 - 1;     if Length > ToPos then     CString[ToPos] := #0;   end; end; exports   SubStr; end. Code: [Select] unit aChiamante; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     procedure Button1Click(Sender: TObject);   private { private declarations }   public     { public declarations }   end;     function SubStr(const CString: PChar; FromPos, ToPos: longint): PChar; cdecl; external 'project1'; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); var   s: PChar;   FromPos, ToPos: Integer; begin   s := 'Test';   FromPos := 2;   ToPos := 3;   Button1.Caption:=(SubStr(s, FromPos, ToPos)); end; initialization   {$I chiamante.lrs} end. Library compiles correctly but when I try to run application, it says that cannot find entrypoint in project1.dll. I cannot understand why. ---------------------------------------------------------------------- Phil · 2008-12-02 14:41 Quote from: "Tommi"Library compiles correctly but when I try to run application, it says that cannot find entrypoint in project1.dll. I cannot understand why. Try declaring SubStr identically to the library. Thanks. -Phil ---------------------------------------------------------------------- felipemdc · 2008-12-04 10:45 In code you posted there is no program. Just a library and a unit. You need 2 projects to run a library: the library project and a program project which uses the library. I think you are trying to run the library. You cannot. You should run a program which uses it. ---------------------------------------------------------------------- Tommi · 2008-12-11 08:21 I solved my problem: I had to use stdcall and not cdecl