Recent

Author Topic: [SOLVED] Lazarus Package Library (lpk) - Linking question  (Read 4205 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1057
[SOLVED] Lazarus Package Library (lpk) - Linking question
« on: December 08, 2011, 04:59:58 pm »
Hi,

For example BGRAControls. If I drop TBGRAButton on form, Lazarus automatically add BGRAControls package as required in project inspector. Then, If I build project, it seems that compiler adds all controls to exe even if I don't use them, because if I delete BGRAControls package from required section and add path to BGRAButton unit manually, then exe is much smaller. How does it work? Exists any compilator optimization switch for strip unused units from project packages?

Regards, Dibo
« Last Edit: December 25, 2011, 01:17:10 pm by Dibo »

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Lazarus Package Library (lpk) - Linking question
« Reply #1 on: December 08, 2011, 07:43:36 pm »
The required packages are added to the uses clause of the lpr. Dropping a TBGRAButton on a form will add BGRAControls in the lpr. The unit bgracontrols pulls in all other BGRAxxx units and registers them in the initialization. Side effect of the registration is that all units are "used". So, stripping unused units wouldn't help since they are used.

AFAIK, the register procedure is only useful for building lazarus. I wonder if this registration shouldn't be ifdef'ed for Lazarus building only use.

lainz

  • Guest
Re: Lazarus Package Library (lpk) - Linking question
« Reply #2 on: December 24, 2011, 07:48:54 pm »
I've the same problem. The way I found is create a separate .lpk with the components I need (in my case with new components inherited from the original ones in the BGRAControls package).

Dibo

  • Hero Member
  • *****
  • Posts: 1057
Re: Lazarus Package Library (lpk) - Linking question
« Reply #3 on: December 25, 2011, 01:16:47 pm »
Problem solved. I didn't notice that Lazarus by default add package unit (BGRAControls) in uses section of .lpr file too. If we delete it or install package with unchecked option "Add package unit to uses" then binary file include only modules that we exactly use. This option is now unchecked by default in latest Lazarus SVN version.

 

TinyPortal © 2005-2018