Difference between revisions of "Using the LCL without Lazarus"
(Bit pointless article but still... Language, layout, Windows-centric warning, category) |
|||
Line 5: | Line 5: | ||
=== Requirements === | === Requirements === | ||
− | + | Things you'll need: | |
− | + | * Free Pascal 2.4.4 | |
− | + | * Lazarus 0.9.30 | |
Tested on Microsoft Windows XP SP3. | Tested on Microsoft Windows XP SP3. | ||
− | Note | + | {{Warning|This article is Windows-oriented you will need to adjust the adjust paths etc for other operating systems as the LCL directories will also differ}} |
+ | {{Note|[[#Lazarus 1.2.6]] has different dependencies between units and the method described here does not work.}} | ||
=== Introduction === | === Introduction === | ||
Line 18: | Line 19: | ||
=== The installation process === | === The installation process === | ||
− | First download | + | First download Free Pascal 2.4.4 and the Lazarus 0.9.30 and install them. |
Our FPC install directory will be this | Our FPC install directory will be this | ||
Line 35: | Line 36: | ||
X:\FPC\2.4.4\units\i386-win32\lcl | X:\FPC\2.4.4\units\i386-win32\lcl | ||
− | Now you can remove | + | Now you can remove Lazarus from your computer. |
− | In the next section we'll | + | In the next section we'll inform the FPC that the LCL has been installed. |
=== The settings === | === The settings === | ||
− | + | Start the FP IDE (included with FPC). Click on the ''Options'' menu and then the ''Directories'' menu item. Select the ''Units'' tab (default). | |
− | Start the FP. Click on the ''Options'' menu and then the ''Directories'' menu item. Select the ''Units'' tab (default). | ||
Add these directories: | Add these directories: | ||
Line 53: | Line 53: | ||
X:\FPC\2.4.4\units\i386-win32\lcl\include | X:\FPC\2.4.4\units\i386-win32\lcl\include | ||
− | Now, you should be able to use the LCL. However, above should be done for all ''Mode''s in ''Options'' if you plan to switch the mode in the future. | + | Now, you should be able to use the LCL. However, above should be done for all ''Mode''s in ''Options'' if you plan to switch the mode in the future. It is easier to edit fp.cfg directly. |
In the next section we'll try out creating a form with a button on it. | In the next section we'll try out creating a form with a button on it. | ||
=== The code === | === The code === | ||
+ | This is the base code: | ||
− | + | <syntaxhighlight> | |
− | + | program lcl_base; | |
− | <syntaxhighlight> program lcl_base; | + | {$mode objfpc} {$H+} |
− | + | uses | |
− | |||
Classes, Interfaces, Forms; | Classes, Interfaces, Forms; | ||
//Interfaces is important | //Interfaces is important | ||
− | + | begin | |
− | + | end. | |
+ | </syntaxhighlight> | ||
First we'll create a form: | First we'll create a form: | ||
− | + | <syntaxhighlight> | |
− | + | program lcl_base; | |
− | + | {$mode objfpc} {$H+} | |
+ | uses | ||
Classes, Interfaces, Forms; | Classes, Interfaces, Forms; | ||
//Interfaces is very important | //Interfaces is very important | ||
− | + | type | |
TForm1 = class(TForm) | TForm1 = class(TForm) | ||
end; | end; | ||
//Our Form class | //Our Form class | ||
− | + | var | |
Form1: TForm1; | Form1: TForm1; | ||
//Declare the Form1 | //Declare the Form1 | ||
− | + | begin | |
Application.Initialize; | Application.Initialize; | ||
Application.CreateForm(TForm1, Form1); | Application.CreateForm(TForm1, Form1); | ||
Application.Run; | Application.Run; | ||
− | + | //We do exactly the same as Lazarus does | |
− | + | end. | |
+ | </syntaxhighlight> | ||
And then we'll create a nice button; | And then we'll create a nice button; | ||
− | + | <syntaxhighlight> | |
− | + | program lcl_base; | |
− | + | {$mode objfpc} {$H+} | |
− | + | uses | |
Classes, Interfaces, Forms, StdCtrls; | Classes, Interfaces, Forms, StdCtrls; | ||
− | + | //Interfaces is very important | |
− | + | ||
+ | type | ||
TForm1 = class(TForm) | TForm1 = class(TForm) | ||
− | + | Button1: TButton; | |
end; | end; | ||
− | + | //Our Form class | |
− | + | ||
+ | var | ||
Form1: TForm1; | Form1: TForm1; | ||
− | + | //Declare the Form1 | |
− | + | ||
+ | begin | ||
Application.Initialize; | Application.Initialize; | ||
Application.CreateForm(TForm1, Form1); | Application.CreateForm(TForm1, Form1); | ||
Form1.Button1 := TButton.Create(Form1); | Form1.Button1 := TButton.Create(Form1); | ||
− | With Form1.Button1 Do | + | With Form1.Button1 Do |
− | + | begin | |
− | + | Parent := Form1; | |
− | + | Visible := TRUE; | |
− | + | Left := 10; | |
− | + | Top := 10; | |
− | + | Width := 100; | |
− | + | Height := 100; | |
− | + | Caption := 'PRESS ME'; | |
+ | end; | ||
Application.Run; | Application.Run; | ||
− | + | //We do exactly the same as Lazarus does | |
− | + | end. | |
+ | </syntaxhighlight> | ||
That's it. Now, you are able to use the LCL without the Lazarus IDE. | That's it. Now, you are able to use the LCL without the Lazarus IDE. | ||
Line 126: | Line 134: | ||
=== Lazarus 1.2.6 === | === Lazarus 1.2.6 === | ||
In order to compile the above example you will need access to units from folder X:\lazarus\components\lazutils. | In order to compile the above example you will need access to units from folder X:\lazarus\components\lazutils. | ||
− | The FP compiler would build the application with ''c like operators'' on | + | The FP compiler would build the application with ''c like operators'' on. |
+ | |||
+ | [[Category:FPC]] | ||
+ | [[Category:LCL]] |
Revision as of 11:39, 17 November 2014
How to use the LCL without the Lazarus IDE?
Requirements
Things you'll need:
- Free Pascal 2.4.4
- Lazarus 0.9.30
Tested on Microsoft Windows XP SP3.
Warning: This article is Windows-oriented you will need to adjust the adjust paths etc for other operating systems as the LCL directories will also differ
Introduction
You aren't forced to use the Lazarus IDE if you want to develop with the LCL. You can use it directly from the Free Pascal Compiler.
The installation process
First download Free Pascal 2.4.4 and the Lazarus 0.9.30 and install them.
Our FPC install directory will be this
X:\FPC\2.4.4\
"X" is the drive letter
The Lazarus install directory will be this
X:\Lazarus\
Then copy the lcl folder.
Copy this folder:
X:\Lazarus\lcl
Paste it to this location:
X:\FPC\2.4.4\units\i386-win32\lcl
Now you can remove Lazarus from your computer. In the next section we'll inform the FPC that the LCL has been installed.
The settings
Start the FP IDE (included with FPC). Click on the Options menu and then the Directories menu item. Select the Units tab (default).
Add these directories:
X:\FPC\2.4.4\units\i386-win32\lcl X:\FPC\2.4.4\units\i386-win32\lcl\units\i386-win32 X:\FPC\2.4.4\units\i386-win32\lcl\widgetset X:\FPC\2.4.4\units\i386-win32\lcl\interfaces\win32
Then click on the Include files tab.
Add this directory:
X:\FPC\2.4.4\units\i386-win32\lcl\include
Now, you should be able to use the LCL. However, above should be done for all Modes in Options if you plan to switch the mode in the future. It is easier to edit fp.cfg directly. In the next section we'll try out creating a form with a button on it.
The code
This is the base code:
program lcl_base;
{$mode objfpc} {$H+}
uses
Classes, Interfaces, Forms;
//Interfaces is important
begin
end.
First we'll create a form:
program lcl_base;
{$mode objfpc} {$H+}
uses
Classes, Interfaces, Forms;
//Interfaces is very important
type
TForm1 = class(TForm)
end;
//Our Form class
var
Form1: TForm1;
//Declare the Form1
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
//We do exactly the same as Lazarus does
end.
And then we'll create a nice button;
program lcl_base;
{$mode objfpc} {$H+}
uses
Classes, Interfaces, Forms, StdCtrls;
//Interfaces is very important
type
TForm1 = class(TForm)
Button1: TButton;
end;
//Our Form class
var
Form1: TForm1;
//Declare the Form1
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Button1 := TButton.Create(Form1);
With Form1.Button1 Do
begin
Parent := Form1;
Visible := TRUE;
Left := 10;
Top := 10;
Width := 100;
Height := 100;
Caption := 'PRESS ME';
end;
Application.Run;
//We do exactly the same as Lazarus does
end.
That's it. Now, you are able to use the LCL without the Lazarus IDE.
Lazarus 1.2.6
In order to compile the above example you will need access to units from folder X:\lazarus\components\lazutils. The FP compiler would build the application with c like operators on.