Sign in Join

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

Mailing lists / fpc-pascal / 2008-06

Shared library with resources which contain bitmaps on Linux -- second try

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Roland Turcan

Hello FPC-Pascal users discussions!

How can I build a shared library which contains many bitmaps loaded dynamically from the code using by:

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 successfully loaded');
    Image1.Picture.Bitmap.LoadFromResourceName (FhMod, 'pict');
  end;
  IF FhMod  0 THEN begin
    FreeLibrary (FhMod);
  end;
end;

I have tried to do it in all ways I know, but loading the shared library was OK, but the LoadFromResourceName raises an exception "Resource XY not found".

Thanks in advance.

Michael Van Canneyt
to Roland Turcan
Roland Turcan wrote 27 lines
Hello FPC-Pascal users discussions! How can I build a shared library which contains many bitmaps loaded dynamically from the code using by: 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 successfully loaded'); Image1.Picture.Bitmap.LoadFromResourceName (FhMod, 'pict'); end; IF FhMod 0 THEN begin FreeLibrary (FhMod); end; end; I have tried to do it in all ways I know, but loading the shared library was OK, but the LoadFromResourceName raises an exception "Resource XY not found".

With FPC 2.2.2, the answer is simple: you cannot.

With version 2.3.1, you can try the new support for resources, and it should work "out of the box".

Michael.

Michael Van Canneyt
to Tom Carly
Tom Carly wrote
> With version 2.3.1, you can try the new support for resources, > and it should work "out of the box". How can you obtain 2.3.1? I cannot find it in the repository...

You can get 2.3.1 only from subversion.

Michael.

Tom Carly
to Michael Van Canneyt
Tom Carly wrote 6 lines
> With version 2.3.1, you can try the new support for resources, > and it should work "out of the box". How can you obtain 2.3.1? I cannot find it in the repository... You can get 2.3.1 only from subversion.

I don't see it in the repository, the last release that is in there is 2_2_2.

Tom

Jonas Maebe
to Tom Carly
Tom Carly wrote
> You can get 2.3.1 only from subversion. I don't see it in the repository, the last release that is in there is 2_2_2.

2.3.1 is not a release, it's the version number of the current main development version. So you have to check out trunk to obtain it.

Jonas

Tomas Hajny
to Michael Van Canneyt: You can get 2.3.1 only from subversion. Michael.
Michael Van Canneyt wrote 8 lines
On Tue, 24 Jun 2008, Tom Carly wrote: > > With version 2.3.1, you can try the new support for resources, > > and it should work "out of the box". > > How can you obtain 2.3.1? I cannot find it in the repository... You can get 2.3.1 only from subversion.

... or you can get a binary snapshot from our FTP server (ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/i386-linux/) if you prefer that to compilation from sources. However, the snapshot is limited to the .tar.gz version, no .rpm or .deb.

Tomas