Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-06

Dynamically loaded resource file

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roland Turcan

Hello all,

How can I generate dynamically loaded resource file *.so on linux to be able to load it?

When I link my *.lrs file into executable then I can read it fine, but I tried to make *.so file which contains resources, then it is not able to read it from and it results an error "Resource "pict" not found".

My code for dynamic resource library:

library libmyres;
{$mode objfpc}{$H+}
uses LResources;
initialization
  {$I libmyres.lrs}
end.

What did I wrong?

My test code for resource file is the following:

procedure TForm1.Button1Click(Sender: TObject);
CONST MYRES_DLL    ='./libmyres.so';
begin
  FhMod := LoadLibrary (PCHAR (MYRES_DLL));
  IF FhMod = 0 THEN begin
    ShowMessage ('Failed to load library ' + MYRES_DLL + '.');
  end else begin
    ShowMessage ('Library ' + MYRES_DLL + ' is sucessfully loaded');
    Image1.Picture.Bitmap.LoadFromResourceName (FhMod, 'pict');
  end;
  IF FhMod  0 THEN begin
    FreeLibrary (FhMod);
  end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  Image1.Picture.Bitmap.LoadFromLazarusResource('pict');
end;
initialization
  {$I main.lrs}
  {$I libmyres.lrs}
end.

Reply by email