Sign in Join

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

Mailing lists / lazarus / 2022-10

Lazarus does not find compiled package, why?

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Bo Berglund

I have been off programming for a while and last time I was using Lazarus was on Linux a year or two ago.
Meanwhile I have done some Windows app maintenance work on existing desktop applications with Lazarus and that has worked fine.

Now I need to start a new project in Windows where I will use a custom package, which is available in the Lazarus 2.0.12 install directory below config\cmplaz\fpserialport where fpserialpkg is the name of the package. The unit with the implementation is named fpserialport.pas.

The package is a wrapper for FPC Serial for RS232 communications.

So I expected that if I enter fpserialport in the uses clause Lazarus would pick it up since it seemed to have been compiled earlier. But no joy...

So I did the following:
- Opened the package file via menu Package/OpenPackageFile and navigated to the lpk file
- Selected "Compile" in the dialog that is shown and Lazarus recompiled the package successfully.

But still it will not find my unit file...

I was under the assumption that every package thus compiled would be known by Lazarus/Fpc...

What can I do to make this work again?

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bart
Bart wrote 7 lines
On Sun, Oct 30, 2022 at 4:50 PM Bo Berglund via lazarus wrote: > What can I do to make this work again? Project Inspector -> Add dependency -> select package you need?

Well, I tried that but my package did not show up in the list... Then I compiled again and this time I also clicked the button next to Compile to add the package to the project.
And now it works...

When I am at it:
Is there a way on Windows to enumerate the existing serial ports so I can put a selector list on the form?

Bo Berglund Developer in Sweden

Reply by email

Unknown author
to Bart: On Sun, Oct 30, 2022 at 4:50 PM Bo Berglund via lazarus Project Inspector -> Add…
"Bo Berglund wrote 5 lines
When I am at it: Is there a way on Windows to enumerate the existing serial ports so I can put a selector list on the form?

You can use Powershell for that:

[System.IO.Ports.SerialPort]::getportnames()

cheers
Samps
Danish developer in Australia

Show quoted text 10 lines
-- Bo Berglund Developer in Sweden -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

Reply by email

Werner Pamler
to Bo Berglund: On Sun, 30 Oct 2022 17:52:16 +0100, Bart via lazarus Well, I tried that but my package…

Am 30.10.2022 um 19:42 schrieb Bo Berglund via lazarus

When I am at it: Is there a way on Windows to enumerate the existing serial ports so I can put a selector list on the form?

I have the following code in one of my projects (Windows-only). It creates a comma-separated list to assigned to a ComboBox.Items.CommaText

function GetSerialPortNames: string;
var
 ? reg: TRegistry;
 ? l, v: TStringList;
 ? n: integer;
begin
 ? l := TStringList.Create;
 ? v := TStringList.Create;
 ? reg := TRegistry.Create;
 ? try
 ??? reg.Access := KEY_READ;
 ??? reg.RootKey := HKEY_LOCAL_MACHINE;
 ??? reg.OpenKey('\HARDWARE\DEVICEMAP\SERIALCOMM', false);
 ??? reg.GetValueNames(l);
 ??? for n := 0 to l.Count - 1 do
 ????? v.Add(PChar(reg.ReadString(l[n])));
 ??? Result := v.CommaText;
 ? finally
 ??? reg.Free;
 ??? l.Free;
 ??? v.Free;
 ? end;
end;

Reply by email

Bo Berglund
to Werner Pamler
Werner Pamler wrote 31 lines
Am 30.10.2022 um 19:42 schrieb Bo Berglund via lazarus > When I am at it: > Is there a way on Windows to enumerate the existing serial ports so I can put a > selector list on the form? I have the following code in one of my projects (Windows-only). It creates a comma-separated list to assigned to a ComboBox.Items.CommaText function GetSerialPortNames: string; var ? reg: TRegistry; ? l, v: TStringList; ? n: integer; begin ? l := TStringList.Create; ? v := TStringList.Create; ? reg := TRegistry.Create; ? try ??? reg.Access := KEY_READ; ??? reg.RootKey := HKEY_LOCAL_MACHINE; ??? reg.OpenKey('\HARDWARE\DEVICEMAP\SERIALCOMM', false); ??? reg.GetValueNames(l); ??? for n := 0 to l.Count - 1 do ????? v.Add(PChar(reg.ReadString(l[n]))); ??? Result := v.CommaText; ? finally ??? reg.Free; ??? l.Free; ??? v.Free; ? end; end;

Thanks, I used the registry way since it was not so hard to do and this will only be a Windows app.

function THanSimulatorMain.ListSerialPorts(LS: TStrings): integer;
var
  I:integer;
  reg:tregistry;
begin
   Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKeyReadOnly('HARDWARE\DEVICEMAP\SERIALCOMM') then
    begin
      LS.Clear;
      Reg.GetValueNames(LS);
      for I := 0 to LS.Count - 1 do
          LS[i] := Reg.ReadString(LS[i]);
    end;
    Result := LS.Count;
  finally
    Reg.Free;
  end;
end;
Bo Berglund Developer in Sweden

Reply by email