Recent

Author Topic: LCL without Lazarus  (Read 11688 times)

SomeoneOpenedTheDoor

  • New member
  • *
  • Posts: 8
LCL without Lazarus
« on: June 29, 2011, 08:17:02 pm »
Hello!

I haven't using the Free Pascal for a too long time. I use Delphi since 2006. But now I must use the Free Pascal. So, I want to create a GUI, and I think the LCL is the best choice. But I don't want to use the Lazarus. Can I download only the LCL somewhere? Or, can you help me, how to get it out from the Lazarus?

Thank you!

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: LCL without Lazarus
« Reply #1 on: June 29, 2011, 08:26:29 pm »
You are not forced to use Lazarus.  The Free Pascal compiler can also be used from the command line.
1.0/2.6.0  XP SP3 & OS X 10.6.8

SomeoneOpenedTheDoor

  • New member
  • *
  • Posts: 8
Re: LCL without Lazarus
« Reply #2 on: June 29, 2011, 08:32:50 pm »
The Lazarus' too heavy. I need something lighter (under 200 MBs or 100 MBs). I don't want Graphical Form Designer or anything. I only want the LCL and the Free Pascal. Because I've tried the WinAPI, but it was  >:( And I can't find any libraries/frameworks/etc. which don't need DLL install or require Lazarus 0.9.x.y. I've chosen the LCL because it doesn't need DLLs and the end-user won't need to isntall anything.

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: LCL without Lazarus
« Reply #3 on: June 29, 2011, 08:37:31 pm »
Then you can download the complier only.

http://www.freepascal.org/download.var

But you will need to get Lazarus temporarily if you want to use the LCL.  It stands for Lazarus Component Library, so is it not surprising that it is in combination with Lazarus.
« Last Edit: June 29, 2011, 08:51:13 pm by Arbee »
1.0/2.6.0  XP SP3 & OS X 10.6.8

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11342
  • Debugger - SynEdit - and more
    • wiki
Re: LCL without Lazarus
« Reply #4 on: June 29, 2011, 08:53:34 pm »
If the goal is only to create a small application, but you have a PC that can run Lazarus, then create your app in Lazarus (it will spare you some headache getting all  the include path etc right)

Don't use the form designer.

create your forms in code

TForm.CreateNew;
TLabel.Create ....

Or better

TCustomForm, TCustomLabel.....
Those do not have published sections => so you save all the RTTI for them. That may save a bit of size in the end

Note, if you use the LCL (even outside Lazarus) you still want to get rid of all RTTI.
There is also a compiler switch, or directive, that you may be able to use (sorry not sure what it is). Then you can recompile the LCL, and make sure no RTTI is used.

No RTTI, also may improve smart linking. Anything that is published cannot be smart linked away => so even if you use the LCL outside Lazarus, you must take steps to reduce size (search wiki / google)

Also you can search through LCL for initialization sections.
E.g the unit "graphics" (or maybe it is units included there like jpg, bmp, png) has/have initialization. And those pull in the entire encoder/decoder for all of those images (that is well over 100 mb in your final app). If you do not use a type of image => remove the initialization...




There is a project called KOL (not sure, just IIRC) google, or search wiki)

SomeoneOpenedTheDoor

  • New member
  • *
  • Posts: 8
Re: LCL without Lazarus
« Reply #5 on: June 29, 2011, 09:07:44 pm »
@Arbee: I know what LCL means. But the Lazarus' using the Free Pascal then I should be able to you the LCL outside of the Lazarus, just with the Free Pascal.
@Martin_fr:
Thanks for your long and nice answer. No, the application size doesn't matter. I just want to use the LCL because it's easy-to-use, user-friendly and programmer-friendly. The KOL requires Lazarus.

So I've downloaded and installed the Lazarus. I've copied the folder "lcl" into the Free Pascal's (version 2.4.4) folder.

I've added the "Forms" into the "uses " section. The compiler said: "Can't open include file: "lcl_defines.inc"". So what can I so? What settings to apply?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11342
  • Debugger - SynEdit - and more
    • wiki
Re: LCL without Lazarus
« Reply #6 on: June 29, 2011, 09:26:37 pm »
You need to set up some include dirs (IIRC -Fi)

But you better compile the LCL, and the include the path with the resulting ppu files. (I haven't got 100% instruction how to)

Easiest is to have Lazarus compile the LCL with your FPC version, and then get the ppu files.

Also be aware: In most cases you need to include the unit "Interfaces"

You need to pre-compile the correct widgetset (folder interfaces). And make sure the result is found by the LINKER

The LCL defines some widgetset stuff as external. It does not actually use the units. So FPC would not even try to find them either.
But the linker will need to resolve those symbols. So the files (*.o) must be in the path for the linker.

This was done, because smart-linking couldn't always figure what was and wasn't used => yet this way the linker would only include what was really used.

Sorry, haven't looked at the details for a long time, so you may need to do some digging on your own there.

SomeoneOpenedTheDoor

  • New member
  • *
  • Posts: 8
Re: LCL without Lazarus
« Reply #7 on: June 29, 2011, 09:36:22 pm »
Ok, I've solved THAT problem. Now I have this things, what you've said: "Undefined symbol: "WSxyz". :) I try to solve this too. Because I think I'm close to the "door".

SomeoneOpenedTheDoor

  • New member
  • *
  • Posts: 8
Re: LCL without Lazarus
« Reply #8 on: June 29, 2011, 09:41:47 pm »
Yesss, compile succesful!

SomeoneOpenedTheDoor

  • New member
  • *
  • Posts: 8
Re: LCL without Lazarus
« Reply #9 on: June 29, 2011, 10:00:10 pm »
:(
So, the FPC can compile this code

Code: [Select]
program firstlcl;

{$mode objfpc} {$H+}

uses
 Interfaces; Forms;

BEGIN

END.

But I get a runtime error, running this:

Code: [Select]
program firstlcl;

{$mode objfpc} {$H+}

uses
 Classes; Interfaces; Forms;

type
 TForm1 = class(TForm);
 private
 public
 end;

var
 F: TForm1;
BEGIN
 F := TForm1.Create(Application);
 F.Show;
END.

It says: "Cannot find window class" Error 1407.
Can anyone help me, please? :(

SomeoneOpenedTheDoor

  • New member
  • *
  • Posts: 8
Re: LCL without Lazarus
« Reply #10 on: June 29, 2011, 10:08:54 pm »
Nothing, it's working. Just use this code:

Code: [Select]
program firstlcl;

{$mode objfpc} {$H+}

uses
 Classes; Interfaces; Forms;

type
 TForm1 = class(TForm);
 private
 public
 end;

var
 Form1: TForm1;
BEGIN
 Application.Initialise;
 Application.CreateForm(TForm1, Form1);
 Application.Run;
END.


:D I did it :) It's working. Thanks for your help, Martin_fr.
If you want, I can explain it here, how to get working the LCL without Lazarus.

Zoran

  • Hero Member
  • *****
  • Posts: 1949
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: LCL without Lazarus
« Reply #11 on: June 30, 2011, 07:18:46 am »
:D I did it :) It's working. Thanks for your help, Martin_fr.
If you want, I can explain it here, how to get working the LCL without Lazarus.

I still don't understand why someone would actually need it, but I can see that one does. :)
So, someone will find this useful, it would be nice of you to explain it. But not here, it will get lost in forum, better create a page in Wiki and put the link here.
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: LCL without Lazarus
« Reply #12 on: June 30, 2011, 12:00:15 pm »
Actually I'd prefer this explanation here instead of in the wiki, because its usefulness is very limited. For the vast majority of users one can simply install the entire Lazarus and ignores the parts that one doesn't want. The cheapest new HDs come with what? 80GB? Even my telephone came with more then 8GB of storage o.O

SomeoneOpenedTheDoor

  • New member
  • *
  • Posts: 8
Re: LCL without Lazarus
« Reply #13 on: June 30, 2011, 12:24:59 pm »
@felipemdc:
I can understand your point of view. But I made the Wiki page. Sorry :| I haven't seen your reply. Maybe you can chek it out:

http://wiki.lazarus.freepascal.org/Using_the_LCL_without_Lazarus

I think it's useful. Can I ask? Why don't you release just the LCL without the Lazarus?

[Edit]
My HD is 1 TB.
« Last Edit: June 30, 2011, 12:26:46 pm by SomeoneOpenedTheDoor »

 

TinyPortal © 2005-2018