Book Image

Getting Started with Lazarus IDE

By : Roderick Person
1 (1)
Book Image

Getting Started with Lazarus IDE

1 (1)
By: Roderick Person

Overview of this book

A good integrated development environment can be the key to creating and delivering software on time and budget. Having a programming language and a development environment that runs on multiple platforms greatly eases and lessens the time taken on creating cross-platform applications. An IDE that is compatible with a legacy code base allows developers to leverage existing libraries in future applications."Getting Started with Lazarus" is a practical, hands-on guide that provides you with a number of clear step-by-step exercises, which will help you take advantage of the power of the Lazarus IDE and Free Pascal to develop software that can be created for cross-platform use."Getting started with Lazarus" discusses developing software with the open source cross platform integrated development environment and the Free Pascal language. We'll learn how to install Lazarus on various platforms such as Linux and Windows, as well as how to create new projects and convert existing Delphi projects to Lazarus projects by learning the differences between Delphi's Pascal syntax and Free Pascal's Object Pascal using a real world example project. We'll learn how to create custom components for use in Lazarus. We'll also learn the basics of documenting a Lazarus project using the Lazarus Documentation Editor. Finally we will learn that the IDE can be rebuilt using a different widget type, specifically GTK 2. Teach yourself the basics of programming with Lazarus and the open source IDE for the Free Pascal language.
Table of Contents (14 chapters)
Getting Started with the Lazarus IDE
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Installing Lazarus in Linux


The Lazarus IDE is available as binary packages for Linux in the Red Hat Package Management (RPM) format, Debian (DEB) format, or in tar gzip format. These packages are available for 32-bit or 64-bit distributions of Linux. Certain distributions of Linux, such as Ubuntu, make Lazarus available through their custom package managers. For information on installing Lazarus using such package management software, check the instructions available from the distribution's website or manuals.

Downloading and installing the Lazarus Linux RPM package

The Lazarus binary RPM package is available from the Lazarus SourceForge.net (http://sourceforge.net/projects/lazarus/files/) download area. Once you have accessed this page, choose the correct link for your platform package, in this case either Lazarus Linux x86_64 RPM for 64-bit platforms or Lazarus Linux i386 RPM for 32-bit platforms. We will be using the 32-bit package for this example. After clicking on the correct link, choose the current release link, in this case Lazarus 1.0.2. Once you are in this area, all the packages needed to install Lazarus are available to be downloaded. Download the following packages:

  • Lazarus-1.0.2-1.i386.rpm

  • fpc-src-2.6.0-0.laz.i686.rpm

  • fpc-2.6.0-0.laz.i686.rpm

Also available is the optional package, fpc-debuginfo-2.6.0-0.laz.i686.rpm, which provides debug information for the system units. This is only needed if you want to do development for Free Pascal itself, which is beyond the scope of this book.

Requirements

Before installing Free Pascal and Lazarus, the following programs are required on the Linux system:

  • GNU as the GNU assembler

  • GNU Id or the GNU linker

GNU Make, this is optional but recommended for easy recompiling of the FPC compiler and Run-Time Library (RTL).

Lazarus requires the following libraries:

GTK+ 2.x or Qt: Most Linux distributions already install GTK+ 2.x. You can also download the libraries from http://www.gtk.org. Qt is also supported by most distributions and is installed together with KDE.

To begin the installation of Lazarus, log into your system as a root user. First install the Free Pascal for the Lazarus package containing the following command:

# rpm -UvH fpc-2.6.0-0.laz.i686.rpm

After the successful completion of this package, next we will need to install the Free Pascal source code package. The Free Pascal source code package is required to operate certain functions in Lazarus. If the IDE cannot find the Free Pascal source, the user will be presented with a warning box with the following message:

The Free Pascal source was not found. Some functions will not work.

To install the Free Pascal source, use the following command:

# rpm -UvH fpc-src-2.6.0-0.laz.i686.rpm

After the successful completion of the installation of the Free Pascal source, all that is left to do is to install the Lazarus IDE itself with the following command:

# rpm -UvH Lazarus-1.0-1.i386.rpm

With the successful completion of these three packages, you are ready to use the Lazarus IDE. Under the GNOME desktop, Lazarus can be accessed from the Applications menu under the Programming submenu.

Downloading and installing the Lazarus Linux DEB package

For Debian-based Linux distributions, the SourceForge.net Lazarus repository contains Debian packages for 32-bit and 64-bit distributions. Access the SourceForge.net repository at http://sourceforge.net/projects/lazarus/files/. For 32-bit Debian-based distributions, choose the Lazarus Linux i386 DEB subfolder. For 64-bit Debian-based distributions, choose the Lazarus Linux amd64 DEB subfolder. Next, choose the current Lazarus release, which at the time of writing is Lazarus 1.0.2. Download all the Debian packages within this folder.

For 32-bit systems:

  • lazarus_1.0.2-0_i386.deb

  • fpc-src_2.6.0-120824_i386.deb

  • fpc_2.6.0-120824_i386.deb

For 64-bit systems:

  • lazarus_1.0.2-0_amd64.deb

  • fpc-src_2.6.0-120824_amd64.deb

  • fpc_2.6.0-120824_amd64.deb

Once the packages are downloaded, install them using the following command:

dpkg -i <package_name>

Install each of the packages for Free Pascal, Free Pascal Source, and the Lazarus IDE.

Lazarus for Ubuntu

There is an Ubuntu repository available at http://www.hu.freepascal.org that contains Lazarus and FPC debs. This repository can be used with apt-get. Before using this repository with apt-get, it first needs to be added to the apt.

First, we need to add the repository's gpg key to the apt keys with the following commands as a root user:

# gpg –keyserver hkp://pgp.mit.edu:11371 –recv-keys 6A11800F
# gpg -a –export 6A11800F | apt-key add -

Next, add the repository by editing /etc/apt/sources.list, adding the following line:

deb http://www.hu.freepascal.org/lazarus/lazarus-stable universe

Once the repository is added to the list of available repositories, Lazarus can be installed with the following commands, again as root:

# apt-get update
# apt-get install lazarus