KEMBAR78
Cross-Platform Pascal with Lazarus | PDF | Cross Platform | Digital Technology
100% found this document useful (1 vote)
518 views6 pages

Cross-Platform Pascal with Lazarus

This document provides resources for learning programming with Pascal using Lazarus and Free Pascal. It discusses cross-platform development between Windows and Mac, importing Delphi projects into Lazarus, and creating application bundles for Mac projects in Lazarus. Useful websites are also listed that provide documentation and guides for programming with Lazarus, Delphi, and cross-platform development.

Uploaded by

luis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
518 views6 pages

Cross-Platform Pascal with Lazarus

This document provides resources for learning programming with Pascal using Lazarus and Free Pascal. It discusses cross-platform development between Windows and Mac, importing Delphi projects into Lazarus, and creating application bundles for Mac projects in Lazarus. Useful websites are also listed that provide documentation and guides for programming with Lazarus, Delphi, and cross-platform development.

Uploaded by

luis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

LEARN PROGRAMMING WITH PASCAL

(RESOURCES)

This document contains notes on cross‐platform development with Free Pascal and 
Lazarus,  plus  some  links  to  web  sites  which  provide  additional  information  on 
programming with Lazarus and Delphi. 
 
Cross-platform development

Lazarus boasts “Write once, compile anywhere”. In the development of this course I 
put  this  to  the  test  by  importing  a  variety  of  Delphi  projects  into  Lazarus  for 
Windows and then importing those projects into Lazarus on the Mac. In so doing, I 
experienced a few problems. this is how I dealt with them… 
 
IMPORTING FROM DELPHI

You  can  import  a  Delphi  project  using  the  Lazarus  Delphi  project  importer.  Make 
sure  you  keep  a  backup  of  your  original  project  before  commencing  this  process. 
Importation  is  started  by  selecting  the  Tools  menu,  then  Convert  Delphi  Project  to 
Lazarus  project.  You  then  need  to  browse  to  a  Delphi  project  file  (ending  with  .dpr) 
and click the Open button. This dialog appears… 
 

 
You  may  experiment  with  the  options  here.  In  most  cases,  accepting  the 
defaults will be ok, so just click Start Conversion.   
The application startup code differs according to which version of Delphi was 
used to create the original project. You may need to edit the Lazarus project file to fix 
any problems here. Open the project (.lpr) file. Select Project, View Project Source. This 
is typical of the project soured I use in my converted projects (don’t change the first 
line – shown below as ‘project1’ which must match the actual name of your project). 
 
program project1; // this must be the actual project name

{$mode objfpc}{$H+}

uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces,
Forms, Unit1

{$R *.res}

begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

Note that the converter uses the compiler mode {$MODE Delphi} and you may 
leave that if you wish. In my projects I specifically use the Object Pascal mode {$mode
objfpc}{$H+} and I have inserted this directive into all the code units in my projects. 
If you receive an error warning that resources are not found, try commentuing out 
the  {$R *.res} directive in the project file. Alternatively, try using these settings in 
Project, Project Options, Miscellaneous… 
 

In  some  cases  you  may  also  need  to  add  the  LCL  package  to  your  project. 
Load the Project Inspector (Project, Project Inspector). If LCL is not shown beneath the 
Required  Packages  branch,  select  Required  Packages  and  click  the  ‘+’  (Add)  button. 
Click the New Requirement tab and select LCL from the Package Name list. Then click 
Create New Requirement. 
 
 
CONVERT WINDOWS LAZARUS PROJECT TO MAC

The  Mac  edition  of  Lazarus  is  able  to  open  projects  that  were  create  on  Windows. 
Even  so,  you  may  find  that  when  you  run  them  on  OS  X,  applications  that  were 
written on  Windows  may be unresponsive. To fix this problem, you need to create 
an ‘Application Bundle’. An Application Bundle is a special directory that OS X uses 
to store various resources required to run the application. By default this directory is 
hidden  (it  is  not  shown  in  Finder).  Even  so,  it  is  needed  to  your  Mac  Lazarus 
projects.  To  create  an  Application  Bundle,  select  Project  Options  from  the  Lazarus 
Project menu.  
Make sure ‘Use Application Bundle for running and debugging’ is checked. 
 

 
   
Now  click  the  Create Application Bundle  button.  This  dialog  should  confirm 
that the Application bundle has been created… 

MORE ON CROSS-PLATFORM DEVELOPMENT

The  Free  Pascal  Wiki  provides  more  detailed  information  on  cross‐platform 
development. In particular refer to the Free Pascal Multiplatform Programming Guide 
http://wiki.freepascal.org/Multiplatform_Programming_Guide  and  Cross  Compiling 
with Lazarus http://wiki.freepascal.org/Cross_compiling. 
 
 
Resources

USEFUL WEB SITES

http://wiki.freepascal.org/
This is an essential guide for Lazarus users. Some pages of particular interest are
listed below…

Lazarus Documentation
http://wiki.freepascal.org/Lazarus_Documentation

Guide to Cross-platform issues with Lazarus


http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide 
 
The Debugger 
http://wiki.freepascal.org/Category:Debugging 

Delphi Basics
Excellent language reference site
http://www.delphibasics.co.uk 
 
Delphi Wikia 
http://delphi.wikia.com/wiki/Delphi_Wiki

Delphi at About.com 
http://delphi.about.com/ 

Dr Bob’s Delphi Programming Clinic


http://www.drbob42.com/

Embarcadero (makers of Delphi)


http://www.embarcadero.com/ 

You might also like