Recent

Author Topic: [Solved]Package does not install Component  (Read 15423 times)

Birger52

  • Sr. Member
  • ****
  • Posts: 309
[Solved]Package does not install Component
« on: August 15, 2018, 06:41:08 pm »
Created  a package and two components.
Both are derived from TPanel - one with an added scrollbar, the other width an added label.

Mostly to learn, but also for later serious use.

Created 2 24x24 .png's, converted to .lrs
Created a page (Tools/Options/Environtment/Component Palette) for my components.

It all compiles just fine.
Without errors that is.
In the package editor, in registered plugins section, when the .pas file is selected, one of the components has a wrong icon (the default one), but is on the right page, the other has the designated icon, but is not set to any page.

Installing and (re)compiling the IDE, only the one with the wrong icon shows up on the designated page - the other one, is nowhere to be found.

Hope someone can help me with this...



Apart from the additional componenets, both files are identical (And basically generated by Lazarus itself):


--------------
unit LabelListContainer;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, StdCtrls, ExtCtrls, Graphics;

type
  TLabelListContainer = class(TPanel)
  private
     FScroller : TScrollBar;
     FscrTop : integer;

  protected

  public
     property scrTop : integer read FScrTop write FScrTop default 16;
     constructor Create(TheOwner: TComponent); override;

  published
     property Scroller : TScrollBar read FScroller;

  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Mine',[TLabelListContainer]);
end;

constructor TLabelListContainer.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  FScroller := TScrollBar.Create(Self);
  FScroller.Parent := Self;
  FScroller.Kind := TScrollBarKind.sbVertical;
  FScroller.Name := 'Scroller';
  FScroller.Align := TAlign.alRight;
  FScroller.BorderSpacing.Top := scrTop;
  FScroller.SetSubComponent(true);
  FScroller.ControlStyle := FScroller.ControlStyle - [csNoDesignSelectable];
  FScroller.Enabled := false;
end;

initialization
  {$I TLabelListContainer.lrs}

end.
--------------
unit LabelList;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, StdCtrls, ExtCtrls, Graphics;

type
  TLabelList = class(Tpanel)
  private
    FHeadLabel : TLabel;
    function GetHeader : string;
    procedure SetHeader(head : string);

  protected

  public
    property HeadText : string read GetHeader write SetHeader;
   constructor Create(TheOwner: TComponent); override;

  published

  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Mine',[TLabelList]);
end;

constructor TLabelList.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  FHeadLabel := TLabel.Create(Self);
  FHeadLabel.Parent := Self;
  FHeadLabel.Align := TAlign.alTop;
  FHeadLabel.Font.Style := [fsBold];
  FHeadLabel.Name := 'HeadLabel';
  FHeadLabel.Caption := 'Header';
  FHeadLabel.SetSubComponent(true);
  FHeadLabel.ControlStyle := FHeadLabel.ControlStyle - [csNoDesignSelectable];
end;

function TLabelList.GetHeader : string;
begin
  GetHeader := FHeadLabel.Caption;
end;

procedure TLabelList.SetHeader(head : string);
begin
  FHeadLabel.Caption := head;
end;

initialization
  {$I labellist.lrs}

end.
« Last Edit: August 17, 2018, 06:49:28 pm by Birger52 »
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

Birger52

  • Sr. Member
  • ****
  • Posts: 309
Re: Package does not install Component
« Reply #1 on: August 16, 2018, 08:03:37 pm »
212 people has been by.
Not one comment.

Used 3 days by now on Lazarus - getting nowhere.

To at least do something I uninstalled, reinstalled - same problem.
So uninstalled and moved file (.pas and .lrs) to a new folder, and created a new packet, and 2 new components from files, installed - exactly same problem.

Created a new packet, a new component (TPanel), and only one. Lazurus does it all. Create folder, give the component a name, and points to one of my .png's for an icon, and my own palette page. Compile. Install.

Used the icon for the component, that previously showed up right - the icon is correct, but the component not installed.
And this gives the same result. Correct icon, and component not installed. And so the whole package is not installed, as there is only one component or unit in it.

As a final resort, also removed the ikon.
Now I get the default icon - surprise, something is doing as expected - the package, unit and/or component is still not installed.

Finally tried creating a package, with one component (from TPanel), with nothing but default, except on LazControls Palette.
No luck. Lazarus can not install components/Units/packages that it creates all on its own.

No errors, no messages, no explanation.


How does one make this thing function to anything but wasting time?


Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
Re: Package does not install Component
« Reply #2 on: August 16, 2018, 08:20:48 pm »
Hello Birger52.
I'm sorry if you feel being ignored.

I read your first post yesterday. I really wanted to inspect your issue but you didn't provide the compilable source code. To do it:

Create a new folder and copy all the necessaries files into it expect: *.bak, the binary and lib folder. Compress the folder and send the zip file to the forum.

Birger52

  • Sr. Member
  • ****
  • Posts: 309
Re: Package does not install Component
« Reply #3 on: August 16, 2018, 11:27:58 pm »
Thx for taking the time.
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: Package does not install Component
« Reply #4 on: August 16, 2018, 11:58:07 pm »
You forgot T in labellistcontainer.lrs for TLabelListContainer name.
Open labellistcontainer.lrs in any texteditor and change 'LabelListContainer' to 'TLabelListContainer'.
and recompile your project and lazarus.
And put the register procudures and images in an extra unit like
minekomp_reg.pas, because when you put images in original units then they are included later in application. And the images are not needed in Application only in lazarus.
Code: Pascal  [Select][+][-]
  1. unit minekomp_reg;
  2. interface
  3.  
  4. uses
  5.   Classes, LResources,  LabelList, LabelListContainer;
  6.  
  7.  procedure Register;
  8.  
  9. implementation
  10.  
  11. procedure Register;
  12. begin
  13.   RegisterComponents('Mine',[TLabelList]);
  14.   RegisterComponents('Mine',[TLabelListContainer]);
  15. end;
  16.  
  17. initialization
  18.   {$I labellist.lrs}
  19.   {$I labellistcontainer.lrs}
  20. end.
  21.  
  22.  
  23.  
« Last Edit: August 17, 2018, 12:00:50 am by Soner »

Birger52

  • Sr. Member
  • ****
  • Posts: 309
Re: Package does not install Component
« Reply #5 on: August 17, 2018, 12:31:39 am »
OK Thx.  :D
This solves the default icon, but does not install the second component.

Kind of late here, so I will look at creating the extra unit tomorrow, with a clear(er) head.

Thx again....
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: Package does not install Component
« Reply #6 on: August 17, 2018, 12:47:50 am »
Except the wrong name in lrs-File your package works without error.
Look at screenshot.
Remove it first from your lazarus  rebuild lazarus and install it again sometimes this helps. (menu -> package -> install/uninstall packages)

Birger52

  • Sr. Member
  • ****
  • Posts: 309
Re: Package does not install Component
« Reply #7 on: August 17, 2018, 11:55:10 am »
So ...

Glad to see it can function... ;)

Your _reg.Pas, solved som and messed up some.

Get an error, saying units are already registered.
Lazarus creates a file - a package registration file, I think it calls it - that duplicates some of the things in your _reg.pas

So I tried to remove the duplicated lines from there - but lazarus puts them back in. ;)
That in turn gives errors abut missing Register procedures in  sources, so had to redo those, and end up with your _reg.pas file, containing nothing but the icons for the IDE.
Whitch is OK ;)

But.
TLabelList does not show up in palettes.
I have tried to reorder the files in hte palette - this changes the PackageRegistration file - but does not install TLAbelList.
I have tried changing, the palette - and it does not make any difference either.
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: Package does not install Component
« Reply #8 on: August 17, 2018, 12:11:56 pm »
Uninstall your component and open from menu package links and remove your package from known package list. Then reinstall your package again.
 (Menu > Package > Package links)

When you get still trouble then remove your package to another directory so lazarus can find it.
when you once load and compile your package then lazarus list it in known packages even without installing it.

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: Package does not install Component
« Reply #9 on: August 17, 2018, 01:19:48 pm »
The attached zip contains your modified components which compile and install fine on my system (Win 10). The palette icons are shown correctly.

The changes are:
  • The {$I xyz.lrs} must be added to the initialization section, not to the registration procedure.
  • As already noted by Soner, the name of the icon resource must match the class name, i.e. including the leading "T".
Duplicate unit messages are shown - well - exactly for this reason: the compiled unit is found at several places. This can happen after failed attempts to install components. My steps usually are (with increasing complexity):
  • Clean compilation of the package (i.e. Package editor > "More" > "Recompile clean")
  • Manually delete the destination folder (usually "lib/<widgetset>")
  • Clean recompilation of IDE ("Tools" > "Configure Build IDE" > check "Clean up" "Clean all" and "Switch after building to automatically" > "Build")
Duplicate unit messages can also appear when several packages are stored within the same directory. Always keep package sources and output folders apart.

I would not name the units like the "T-less" components, the risk of using this as a component name is too high. And I am too lazy to investigate if this would cause any issues - just don't do it. A good naming stragegy for units is to add a specific prefix, e.g. TA for all TAChart units, fps for all (well - most) fpspreadsheet units.

Birger52

  • Sr. Member
  • ****
  • Posts: 309
Re: Package does not install Component
« Reply #10 on: August 17, 2018, 04:52:59 pm »
Uninstalled and removed.
Making sure, there are no traces anywhere (Package Link,  Package Graph, Install/unistall, available)
Created new folders, out of Lazarus reach.
Moved files to these new folders.
Rebuild Lazarus as suggested.
Again making sure, there are no traces of them anywhere.
Moved folders back into Lazarus' reach.
Created two new packages - one for each component.
Named packages labellistpck and labellistcontainerpck.
A little renaming of the files that sets icons.
Moved the inclusion of icon-resources to Initializers
[
doesn't seem to make any difference at all tho...
...icon.pas files has nothing but the icons now, and this approach only to not load icons into final application, should I ever get that far.
]

First labellistpck.
Compiles clean without error.
Install with no problems.
Package can now be found in Package Link, according to Package Graph, it is part of the IDE
In Package install/uninstall it is listed as installed:
Filename:  C:\ZZ Mine Data\MineDelphi\Mine Komponenter\LabelList\labellistpck.lpk
Current state: installed, RunAndDesignTime
TLabelList is NOT available on any palette.

Next labellistcontainerpck
Exact same.
Filename:  C:\ZZ Mine Data\MineDelphi\Mine Komponenter\LabelListContainer\labellistcontainerpck.lpk
Current state: installed, RunAndDesignTime

Apart from Lazarus now has a palette called Mine, that contains TLabelListContainer - but not TLabelList.

Suggestions?
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

Birger52

  • Sr. Member
  • ****
  • Posts: 309
Re: Package does not install Component
« Reply #11 on: August 17, 2018, 05:15:38 pm »
Just info.
Did create a test, that uses the TLabelList component.
Have to add it manually as it is not on any palette - adding lists manually, will not really be an option tho.
But it actually functions as it should.
So the only problem seems to be, that Lazarus does not want to have this one of my components on it's pallete(s).
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: Package does not install Component
« Reply #12 on: August 17, 2018, 05:23:14 pm »
Did you try to install the modified package that I posted in reply #9 which is installing correctly here? There is something which you are doing wrong and before we cannot identify this you will always run into the same issue.

P.S. Since that package uses your component names and the IDE does not like duplicate component names you must uninstall you own packages first before you can install mine.

Just to make sure that you do the installation correct:
  • Go to "Package" > "Open package file (*.lpk)".
  • Navigate to "minecomp.lpk". Load it into the IDE.
  • This opens the package editor.
  • Click "Compile"
  • Then click "Use" and in the dropdown "Install". Confirm to "Rebuild Lazarus" (or similar).
  • This recompiles the IDE. After soem time the IDE restarts, and your components should be in the palette "Mine"
  • If not: Did you ever play with the arrangement of icons to different palettes ("Tools" > "Options" > "Component palette"? I've seen sometimes components disappearing from the palette this way. So, please click "Restore Defaults" although this will resume your arrangement of components back to default.
« Last Edit: August 17, 2018, 06:19:15 pm by wp »

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: Package does not install Component
« Reply #13 on: August 17, 2018, 06:04:08 pm »
Your packages of reply #10 are compiling and installing fine, icons do appear on the palette, no issues...
So, I don't know what you are doing wrong.

BTW, why are you using two packages, and a separate unit for including the icon. I think it's not wrong but not very convenient. I would not spread units of the same subject over individual packages - this will be pain to manage. Splitting a large library (like JVCL) into separate packages is justified only if it consists of independent parts, or if you want to avoid keeping the basic functionality apart from the add-ons, or if you want to separate runtime from designtime code.

I'd put everything into a single package (without the icon units), but add a registration unit which calls RegisterComponent and adds the lrs for each component that you want to register. The Register procedures should be removed from the individual component units. Since you don't call anything from the registration unit at runtime you avoid linking the palette icon into the binary of your application. Moreover, if you register both components in the same call (i.e. RegisterComponents('Mine', [TLabelList, TLabelListContainer]), then you can determine the order in which the icons appear on the palette.

The registration unit should be the only unit of a "normal" package for which the "Register unit" box is checked in the package editor.

I am attaching a new zip containing the package how I would do it. Again it is compiling and installing correctly.

Created new folders, out of Lazarus reach.
...
Moved folders back into Lazarus' reach.
What is this for? Just create a folder anywhere and put your files there and keep them there. Not 100% sure but I would not put the package into one of the folders of the Lazarus installation. I always want to keep my own work away from the installed program. Suppose you must delete Lazarus: If you don't remember that you have your own files in there they will be gone.

So, the procedure is: Find yourself a place for your work, I have "d:\prog_laz" which contains all my projects. Create a folder for the package in there and unzip the downloaded file to here. Then open the lpk file by Lazarus like I described above and install it. Don't move files around after installation.

BTW: what is your OS?

Birger52

  • Sr. Member
  • ****
  • Posts: 309
Re: Package does not install Component
« Reply #14 on: August 17, 2018, 06:09:37 pm »
Well - I didn't.
So I did now.
And it did as expected  _ I did, at least - not make any difference.

The container shows up in the palette - the list does not.
Filename:  C:\ZZ Mine Data\MineDelphi\LazHelp\minekomp.lpk
Current state: installed, RunAndDesignTime
No errors, no messages...
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

 

TinyPortal © 2005-2018