Author Topic: Resource: How to include binary resource?  (Read 5877 times)


  • Newbie
  • Posts: 3
Resource: How to include binary resource?
« on: July 13, 2006, 02:17:35 am »
Working on a SpellCheck / Thesaurus component for Lazarus (It's actually 98% complete... I'll post it once I figure out how  :shock: )

Currently the Dictionary resides in a 5-meg file which you have to link to with a property and then include with your .exe... is there a way to get Laz to swallow this file into the .exe (and then link to it programmatically)? This will make deployment easier for new ppl, since they won't have that extra file to go find.

I'm thinking a huge binary resource... it's not entirely clear how I'd go about creating it. If anyone can point me along the way it'd be helpful.


  • Administrator
  • Hero Member
  • *
  • Posts: 3541
RE: Resource: How to include binary resource?
« Reply #1 on: July 13, 2006, 02:36:08 am »
On Windows you can create a .rc resource file, compile it with "windres" software that comes with lazarus. That will produce a .res file, which you can link into the executable putting this:

{$IFDEF Win32}
  {$R myresource.res}

In the main program file (or other unit).

A RC file has statements like this:

101               ICON                    "iconfile.ico"

You can use windres like this, on the command line: windres -i magnifier.rc -o magnifier.res

There are some Windows API functions you can use to load the resource from the executable into memory.

If you want, you can use the Virtual Magnifying Glass as an example. Download the source code here:

The source code contains a rc file, a batch script to compile that file, and source code that loads the contents of the resources into memory and uses them. It also contains IFDEFs to load the resources from files on Unixes, because on Linux you usualy don´t link anything into the executable, you keep things on external files.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Resource: How to include binary resource?
« Reply #2 on: July 13, 2006, 07:38:58 pm »
See also the FAQ on the wiki.

I don't know how well it works with large files. It will be hard on the compiler, but I think quiet efficient in the program.


  • Full Member
  • ***
  • Posts: 234
RE: Resource: How to include binary resource?
« Reply #3 on: July 13, 2006, 08:33:28 pm »
I think a external one will still be the best, then you should be able to keep a central spelling "database?".
If you want to update the one, you don't NEED to update the other. If you want to add a language, you just add a "database?".
The FRED Trainer. (Training FRED with Lazarus/FPC)


TinyPortal © 2005-2018