Monday, September 10, 2012

Installing Lazarus on MacOS X (Step by Step)

Installation

This document describes installation on Apple Mac OS X desktops/laptops.

Apple Developer Tools

You need the Apple Developer tools. They can be installed from the original Mac OS X installation disks or downloaded from the Apple Developer Connection (ADC), which requires free registration: http://developer.apple.com/.

Install Packages / Released version

Installation from disk images

Download the three disk images (.dmg files) for fpc, fpcsrc and lazarus from either of the following links:
Open up each disk image and install in this order: 1. fpc 2. fpcsrc 3. Lazarus
After installation the Lazarus application can be found in /Developer/lazarus/, the FPC source files in /usr/local/share/fpcsrc.
If you receive a "Can't find unit Interfaces used by Project1" error on trying to compile a blank form, check the following settings in Lazarus (should be set by default):
Environment | Options
  Lazarus directory: /Developer/Lazarus
  Compiler path: /usr/local/bin/ppc386 (PowerPC Macs: /usr/local/bin/ppcppc)
  FPC Source: /usr/local/share/fpcsrc
Project | Options
  All paths blank
  LCL Widget Type: default (Carbon beta)
Project | Inspector
  Required Packages
     LCL

Note - different versions of Lazarus depend on particular versions of the FreePascal compiler and will not work with other versions.
Another common problem is that the versions of fpc and fpcsrc are different.
This is the easiest way to install Lazarus on Mac OS X.

Installation using fink

To obtain the up-to-date release versions of lazarus (0.9.30) AND freepascal (2.4.4) use fink, a package manager for Mac OS X. The extra bonus of fink is easy installation as well as clean removal of a huge number of other open source software packages, including FreePascal crosscompilers for other processors and systems. The choice for lazarus is between an Aqua (preferred by most) and a gtk2 look of lazarus:
$ fink install lazarus-aqua
or
$ fink install lazarus-gtk2
This also installs a number of other packages, such as the FreePascal compiler, the lazarus sources, gtk2 libraries and more. At the prompt, whether you want to install these additional packages, simply hit RETURN and go for a coffee. It really takes some time to build all packages, in particular on older Macs.
After installation, Lazarus can be started from the folder /Applications/Fink/. The actual details of fpc and lazarus are in subdirectories of /sw
With both (Aqua AND gtk2) looks, these widget sets for your program are supported on Intel- and PowerPC-Macs:
carbon (Aqua), gtk2, nogui
On Intel-Macs these additional cross platform widget sets are supported:
carbon (Aqua) for powerpc, win32 and wince.
Projects with the gtk1 widget set are also supported on 10.4 and 10.5 through the lazarus-common-gtk1 package. On 10.6, gtk1 libraries are deprecated in general and you have to port your project to the gtk2 or carbon widget set.

Installation using SVN

To get the current development version see below.

Install from Source / Development version

You need the latest stable released FPC installed in order to compile the development version.

Download and install a compiler

Download and install the FPC package: https://sourceforge.net/project/showfiles.php?group_id=89339
There are two development versions of the compiler: 2.6.x is stable version without new features - only bug fixes. The unstable version 2.7.x comes with lots of new features but sometimes also with bugs. Best is to download and install fpc 2.6.x. Some daily snapshots can be found here. Keep in mind that these are daily snapshots and that you can have bad luck and get a buggy version. The probability is about 1:30. So if the version is buggy try another day or use the released packages instead.

Download the sources via svn

  • Note: IF the current SVN of FreePascal can not be compiled using the stable release of FreePascal that comes with the current stable version of Lazarus (FPC 2.6.*), you will need a newer compiler. In order to compile the latest versions of FPC, first install a precompiled 2.6.* series compiler. You can get a compiled version of FPC 2.6.* at http://www.freepascal.org/download.var. Note: only do this if the instructions below do not work.
The sources are kept in a version control system called subversion or short svn:
  • 10.5 and higher already contains svn clients. Users of earlier versions must install SVN for Mac OS X. A good package is provided by Martin Ott. You can also use fink. SVN clients with GUI (graphical user interface) are available from Versiontracker. A quite handy client, which integrates in Finder, is SCPlugin.
Create a directory, where you would like to put the sources. You don't need to be root to do this. Any normal user can do this. First create a directory for fpc
(e.g. /Users/username/freepascal)
then open a terminal and do the following:
This will create a directory called 'fpc', which can be later used in the IDE. Hint: To download/update the latest changes you can simply do
[]$ cd /Users/username/freepascal/fpc
[]$ svn up
Building fpc
[]$ make clean all
[]$ sudo make install
Then download lazarus
This will create a directory called 'lazarus'. To update the latest changes:
[]$ cd /Users/username/freepascal/lazarus
[]$ svn up
Building lazarus
[]$ make clean all
Then start lazarus either via command line or by double click in the finder:
 open lazarus.app

Known issues

  • FPC 2.4.4 has a bug. You can not compile the IDE with the range check flag -Cr.
  • On OS X 10.4 you have to manually uninstall any previous version before installing a new dmg. Delete the following files and folders: 
    • /Developer/lazarus
    • /Library/Receipts/lazarus.pkg
    • /etc/lazarus
    • /usr/local/bin/lazbuild

First Steps

The carbon interface has matured and is probably preferred over the gtk2 interface by most users of lazarus:
  • The carbon IDE looks somewhat nicer, although autosizing does not yet work correctly. Therefore, some dialogs look pretty bad until you enlarge them manually.
  • Sometimes the blinking cursor vanishes after closing a file. Just switch to another page and back
Reactions:

0 comments:

Post a Comment