Loading self-build shared lib in lazarus failed
Original Reporter info from Mantis: PatrickS
-
Reporter name:
Original Reporter info from Mantis: PatrickS
- Reporter name:
Description:
It is not possible to load a self created library (created with lazarus 2.6.4/ and svn-Version) in a lazarus programm. BUT it is possible to load other created shared libs. Inder Linux (x64) and Windows (x64) it is possible.
Steps to reproduce:
Compile the following lib under armhf with compiler 3.1.1 under linux ant try to load it in the programm beneth the lib:
Code for the shared lib:
library project1_dll;
{$mode objfpc}{$H+}
uses
Classes
{ you can add units after this };
function Patrick_Add(a,b:integer):integer;cdecl;export;
begin
Patrick_Add:=a+b;
end;
exports Patrick_Add;
begin
end.
CODE for the programm:
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,dynlibs
{ you can add units after this };
type TPatrick_Add=function(a,b:integer):integer;
var mylib:TLibHandle = dynlibs.NilHandle;
MyFunc: TPatrick_Add;
result:integer;
begin
Writeln('Hello');
mylib:=LoadLibrary('C:\Users\USERNAME\Desktop\Proba\project1_dll.'+sharedsuffix);
if mylib = dynlibs.NilHandle then Writeln('Problem found')
else begin
Writeln('OK');
MyFunc:=TPatrick_Add(dynlibs.GetProcedureAddress(mylib,'Patrick_Add'));
if MyFunc<>nil then Writeln('Func Found');
//Writeln(MyFunc(1,1));
end;
Writeln(GetLoadErrorStr);
Readln;
end.
Additional information:
Tried to load the lib under fpc-2.6.4 (armhf) and 3.1.1(armhf)
Mantis conversion info:
- Mantis ID: 28545
- OS: Linux (Wheezy)
- OS Build: 7
- Build: 3.1.1
- Platform: armhf
- Version: 3.1.1