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 under other OSes such as FreeBSD or Mac OS X


Although Lazarus is targeted mainly for Linux and Windows operating systems, there are also binary packages available for Mac OS X. FreeBSD makes Free Pascal and Lazarus available through its ports collections. It is also possible to run Lazarus on other operating systems, such as Haiku, by compiling Lazarus and Free Pascal from source.

Installing Lazarus on Mac OS X

Lazarus and Free Pascal are available as disk images (.dmg files) for Mac OS X for Intel-based Macs and PowerPC-based Macs from the SourceForge.net Repository at http://sourceforge.net/projects/lazarus/files/. The Mac OS X versions of Lazarus require the installation of Apple Developer Tools. This can be installed from the Mac OS X installation disks or downloaded from the Apple Developers Connection (ADC) at http://developer.apple.com. ADC requires registration, which is free. Once these tools have been installed, go to the SourceForge.net repository and select the correct subfolder for your Mac, Lazarus Mac OS X PowerPC, or Lazarus Mac OS X i386. Then choose the latest release of the Lazarus subfolder, which is Lazarus 1.0.2 at the time of writing, and download the disk images. For Mac OS X PowerPC, download the following:

  • fpcsrc-2.6.0.powerpc-macosx.dmg

  • fpc-2.6.0.powerpc-macosx.dmg

  • lazarus-1.0.2-powerpc-macosx.dmg

For Mac OS X Intel:

  • fpcsrc-2.6.0.powerpc-macosx.dmg

  • fpc-2.6.0.powerpc-macosx.dmg

  • lazarus-1.0.2-20121009-i386-macosx.dmg

Once the disk image files are downloaded, install them in the following order:

  • fpc: The Free Pascal compiler

  • fpcsrc: The Free Pascal compiler source

  • lazarus: The Lazarus IDE

After installation, the Lazarus application can be found in /Developer/lazarus, the Free Pascal source files are in /usr/local/share/fpcsrc.

Installing under FreeBSD

The FreeBSD ports collection contains, at the time of writing, 91 separate ports for Free Pascal. These ports are divided into subcategories such as graphics, math, and multimedia. This is in keeping with the FreeBSD philosophy of only installing necessary packages to keep this system as small as possible and easily maintainable. For Lazarus, the ports collection contains six separate ports; among them are GTK+, GTK2+, and Qt toolkit versions of Lazarus. The simplest way to install Free Pascal is to log in as a root user and issue the following commands:

# cd /usr/ports/lang/fpc
# make install clean

This will install the Free Pascal meta port. Meta port in FreeBSD is a port that installs multiple sub ports. In this case, the fpc meta port will install all 91 Free Pascal port. In addition to these ports, any requirements not installed on the system will also be automatically installed. If you are an advanced FreeBSD user and know exactly the type of development you are going to do with Lazarus and Free Pascal, you can install only the needed individual ports of the 91 available.

The easiest way to install Lazarus is to use the meta port located in /usr/ports/editors/lazarus. Remain logged in as root and issue the following commands:

# cd /usr/ports/editors/lazarus
# make config

This will bring up the Options for Lazarus dialog box as seen in the screenshot that follows. In this dialog, you can choose to either install the GTK2 interface or the QT4 interface for the IDE. You can only choose one of the two options, choosing both will cause an error during installation.

After selecting the desired interface and selecting OK, continue installing by issuing the following command:

# make install clean

Once the installation is complete, Lazarus will be installed in /usr/local/bin and can be started with the following command:

$ /usr/local/bin/startlazarus

For operating systems that don't have a binary package available, Lazarus can be built using the source code.

Installing from source

Lazarus and Free Pascal source code is available through Subversion (SVN). The SVN repositories provide the most up-to-date source code available. The SVN repositories also allow you to track only the changes in the source. Although, SVN access requires an Internet connection, it does not require the user to be root.

When downloading the source, you need to make sure that you have enough free space. The initial checkout requires approximately 270 MB of free space. To begin the installation from source, first make sure that current working folder is the folder that you want the source code to be present in. For the initial checkout, use the following command:

$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk/ lazarus

This will download the latest available source code to the lazarus subfolder, which will be created in the current folder. Once the download is completed, compile the source code by using the following command:

$ cd lazarus
$ make

Once the build is complete, Lazarus can be started from the current folder with the following command:

$ ./startlazarus

To keep Lazarus up-to-date, from the parent folder of the Lazarus source code, use the following commands:

$ svn update lazarus
$ cd lazarus
$ make clean all

This will rebuild the Lazarus IDE without packages. After the build is done, then use the following command to link to the existing Lazarus packages:

$ ./lazbuild –build-ide=

Tip

If you are building from source on a BSD-based system, you will need to use gmake instead of make.

On the Windows platform, if you have Delphi installed, you must modify your PATH variable or delete the Delphi version of make.