[Lazarus] Resources

Donald Ziesig donald at ziesig.org
Sun Nov 24 03:26:36 CET 2013

Hi All!

I have been trying to use a resource file (mydata.rc) to include some 
bitmap images in an app but with no success.  For simplicity, I have 
pared the rc file to a single line:

pix2     BITMAP "/home/mydir/Desktop/myapp/2.bmp"

I have the following lines in my main unit:

{$R *.lfm} // the original
{$R mydata.rc}

mydata.rc is being compiled.  It generates lib/x86_64-linux/mydata.res 
as expected.

I can see the following in the compiled lib/x86_64-linux/mydata.res file 
using od

B nul   I nul   T nul   M nul   A nul   P nul


P nul   I nul   X nul   2 nul

followed by the header of a bitmap image, so I am pretty sure that the 
resource compiler (windres) is working correctly.

When I try to load the bitmap using:

   Image1.Picture.LoadFromLazarusResource('PIX2');  // Tried 'pix2' as well

I constantly get Resource "pix2" not found.

I put some diagnostics in LResources.pp and I can see other resources 
being found, and pix2 being sought but it never finds a resource from 
the mydata.res file.

It appears that whatever (I'm guessing here) has to be done to include 
the resources from mydata.res into the executable is not happening.

I am using Lazarus V 1.1, and FPC V 2.6.2

Can anyone point me in the right direction?


Don Ziesig

P.S.  I started with PNG graphics and ended up with BMP only because 
that seemed to be the least common denominator in the all of the docs I 
could find.

More information about the Lazarus mailing list