Getting Lazarus

From Free Pascal wiki
Revision as of 16:05, 8 February 2010 by Etrusco (talk | contribs) (Include link to Florian's Mercurial mirror.)
Jump to navigationJump to search

Deutsch (de) English (en) español (es) français (fr) 日本語 (ja) polski (pl) português (pt) русский (ru) slovenčina (sk)

Downloading releases

From SourceForge

Binary releases for various platforms are also available via the Lazarus Sourceforge download area.

Getting Lazarus from our Ubuntu repository

On www.hu.freepascal.org there is a Ubuntu repository with Lazarus and FPC debs.

Short version: get Lazarus

In the sections that follow, there's a complete list of the commands you need to type at the console to download and install Lazarus on an Ubuntu system. If you're impatient, this section will just give you what you need to get it installed without going through every part of the process line by line.

Select and copy the following script, and save it as a file in your home directory named getlaz:

 #!/bin/sh
 gpg --keyserver hkp://pgp.mit.edu:11371 --recv-keys 6A11800F
 gpg --export 6A11800F | apt-key add -
 echo "deb http://www.hu.freepascal.org/lazarus/ lazarus-stable universe" \
     >/etc/apt/sources.list.d/lazarus.list
 apt-get update
 apt-get install lazarus

At the shell prompt, type this to prepare the script for execution, and to execute it (you can copy these lines and paste them into your shell using Shift+Insert):

 chmod +x getlaz
 sudo ./getlaz

The process will download around 100Mb of data from the Lazarus repository and the standard ones. It will take at least five minutes, even with a fast connection. Any time it stops to ask for confirmation of any step, answer "Y" for yes.

When it finishes and returns to the shell prompt, you're set. Look in the "Development" section of your Ubuntu menu; Lazarus will be there and functional.

Long version: step by step

Now, for completists, here's the same instruction step by step. You can ignore it if you followed the above instructions successfully. Please remember to come back to the wiki and put in any tested, reliable changes that might clarify this section!

Add the key

Download the key from the public key server:

 gpg --keyserver hkp://pgp.mit.edu:11371 --recv-keys 6A11800F

Add it to the apt system:

 gpg --export 6A11800F | sudo apt-key add -

You can see the list of apt keys with:

 sudo apt-key list
Add the repository

You can use synaptic for this or edit the /etc/apt/sources.list directly. For the stable repository, add the line:

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

Or using a console app. do:

 echo "deb http://www.hu.freepascal.org/lazarus/ lazarus-stable universe">/etc/apt/sources.list.d/lazarus.list

For the testing repository:

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

Or similarly, using a console app. do:

 echo "deb http://www.hu.freepascal.org/lazarus/ lazarus-testing universe">/etc/apt/sources.list.d/lazarus.list

Note that trying the echo command you may get "bash: /etc/apt/sources.list.d/lazarus.list: Access denied" and the same with sources.list, even with sudo. Fortunately manually editing the file also works in this case.

Install Lazarus

Now You can install Lazarus with apt:

 sudo apt-get update; apt-get install lazarus

Install Lazarus on Fedora

Lazarus is part of the standard Fedora-repositories since Fedora version 9. You can install it using the command-line ('yum install lazarus') or by using the 'add/remove software' wizard. If you want to install Lazarus during the installation of Fedora, you have to enable the additional repositories during install.

Once installed you can find Lazarus in the 'Applications/Programming' menu.

Note that if you want to develop gtk2 applications, you also have to install 'gtk2-devel'.

Development versions from SVN

Getting SVN

You may download a SVN Client for Windows in http://tortoisesvn.tigris.org/ A SVN command line client is available from the official SVN website for many platforms.

On Linux, it is recommended to install subversion using the package management system offered by your distribution. For example:

sudo apt-get install subversion

Using SVN

Using the command line

To get Lazarus for the first time:

Open a terminal/command prompt, change to the directory you wish the Lazarus folder to be created in and type:

 svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus

To update Lazarus sources:

Open a terminal/command prompt, change to the lazarus directory and type:

 svn update

For compiling see here.

Alternative URLs

Sometimes the URL of repository given above does not work, because between the svn server there is a http-proxy server. That server usually claims to be a 'transparent' proxy, but still doesn't pass your svn commands correctly to the svn.freepascal.org server.

The svn.freepascal.org server also listens on port 8080. Maybe the proxy doesn't interfere with http trafic on that port, so you can try:

svn co http://svn.freepascal.org:8080/svn/lazarus/trunk lazarus 

The Lazarus svn repostory is mirrored on sourceforge with a delay of 15 minutes using fpsvnsync. The sourceforge repository uses the https protocol. Proxy servers usually don't interfere with that protocol. You can check out form sourceforge using the following command

svn co https://svn.sourceforge.net/svnroot/lazarus/trunk lazarus

The FPC and Lazarus svn repostories are also mirrored to svn2.freepascal.org. You can check out from svn2.freepascal.org with

svn co http://svn2.freepascal.org/svn/lazarus/trunk lazarus

If you own the proxy server, or are friends with the person who does, there are details of setting up a proxy to pass svn commands here: http://subversion.tigris.org/faq.html#proxy This contains an example for squid. Remember to set up the client to use the proxy ! (For TortoiseSVN, see settings/network)

Using TortoiseSVN for Windows

TortoiseSVN integrates itself with Windows Explorer. After installation, all commands are available from inside Windows Explorer through right-clicking on a directory or file.

Check out a working copy using TortoiseSVN, go to Run and paste the command below:

tsvn:http://svn.freepascal.org/svn/lazarus/trunk

To get Lazarus for the first time:

  • Open Windows Explorer
  • Create a directory where you want to put the files from the SVN server
  • Right click on the newly created directory
  • Select SVN Checkout... on the popup menu

TortoiseSVN Main Menu.png

  • In the next dialog you enter the URL for Lazarus server source:
http://svn.freepascal.org/svn/lazarus/trunk
  • Watch how TortoiseSVN imports the file tree from the server. This can take some time to complete.


To update Lazarus sources:

  • Open Windows Explorer
  • Right click on the source directory
  • Select SVN Update on the popup menu

TortoiseSVN Main Menu Update.png

Scripts

Lightning: Here is a windows batch script that takes care of checking out and updating Lazarus from SVN to a subdirectory and even basic error fixing, because i have no way of knowing where Lazarus is installed it cannot compile or copy the files to your working Lazarus instalation. Please save the script as getlaz.bat or some other name, however there is no warranty of any kind, use at your own risk, put it in a test directory first and make sure there is no subdirectory already called lazarus.

@echo off
REM Script for checkout and update Lazarus from SVN
echo.

REM Check if lazarus directory exists to update or checkout first
if exist lazarus (
echo Updating Lazarus, please wait ...
cd lazarus
svn update
if %errorlevel% NEQ 0 goto CleanupLaz
cd ..
goto Exit
)

echo Checking out Lazarus for the first time, this might take a while ...
svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
goto Exit

:CleanupLaz
echo.
echo Something went wrong, trying to fix any problems if possible  ...
svn cleanup
if %errorlevel% NEQ 0 (
cd ..
echo.
echo Cleanup Failed ! Please check or delete/move/rename the lazarus subdirectory ...
goto Exit
)

cd ..
echo.
echo Cleanup complete please run the script again.
:Exit


Matthijs: In Linux I use a script (it is not very sophisticated, but does the trick) to download the latest SVN-version for Lazarus. Before I copy it here I'll explain my system. In my home-directory I have a special cvsroot-directory. In this directory I have a script for downloading Lazarus and other interesting projects. Lazarus is installed in /usr/share/lazarus. Before building a new version from SVN I make a backup, just in case the current svn is unstable. This is done by moving the /usr/share/lazarus directory to /usr/share/lazarus.bu To adapt the script to your system you only need to alter the constants defined at the start of the script. But without further ado, here is the script. But (big but) it is given without any guarantee. :) If things break you are on your own.

#!/bin/bash

# before you can use this script you have to checkout all files
# so first do a
# svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus

#Define some directories
BASEDIR=/usr/share/
LAZCVSDIR=~/cvsroot/lazarus/
LAZDIR=/usr/share/lazarus/
LAZBACKUP=/usr/share/lazarus.bu

#Remove old backup if it exists
date +"%T %tStart"
if [ -d $LAZBACKUP ]
then 
  date +"%T %tRemoving old backup"
  rm $LAZBACKUP -fr
else
  date +"%T %tNo backup to remove"
fi

date +"%T %tCreating copy of lazarus dir"
cp -R $LAZDIR $LAZBACKUP

#Getting stuff from svn
date +"%T %tUpdate lazarus"
svn update lazarus > ~/cvs_update.log

#Copying cvs-files to our laz dir.
date +"%T %tcopying files"
cp -Rf $LAZCVSDIR $BASEDIR --reply=yes

#Make and building of lazarus
date +"%T %tmake lazarus" 
cd $LAZDIR
make > /dev/null
date +"%T %tmake the packages"
make idepkg > /dev/null
date +"%T %tFinished"

Installing the compiler

Here are some hints how to install the development version of fpc (at the moment 2.5.1), which contains new features, bug fixes but is less stable and contains new bugs. The compiler is not included in the Lazarus SVN, but has its own FPC SVN. You must install first the latest released fpc. See here: Installing the Free Pascal Compiler.

Create a directory and download fpc from svn:

mkdir -p ~/freepascal
cd ~/freepascal
svn co http://svn.freepascal.org/svn/fpc/trunk fpc

This will take some time.

There are many ways to compile and install FPC. You can use plain make (see below), but it is recommended to build a fpc package for your distribution (.deb or .rpm file). A fpc package allows to easily uninstall, upgrade and downgrade it and a package makes sure that all files are installed at the common places. So if something goes wrong, other users know how to help you.

Building a fpc debian/ubuntu package from fpc svn

Important: This script does not create the official debian/ubuntu packages. It creates a fpc package that contains the compiler and all packages.

To build the package you need to install some packages:

sudo apt-get install libgpmg1-dev fakeroot libncurses5-dev build-essential

Go into your lazarus source directory. The directory must be writable.

cd ~/freepascal/lazarus/tools/install
./create_fpc_deb.sh fpc ~/freepascal/fpc

If you get an error about a missing file or tool you may have to install a missing package. If you get a compilation error your installed fpc is not the released compiler or you were unlucky and fetched a fpc svn reversion that contains a bug. Search help on the mailing list, forum or chat. If it ran through you now have a deb file, which you can install:

 sudo dpkg -i fpc_2.5.1-091121_i386.deb

The file name is different for you. The next step is to compile the lazarus svn with this new compiler and tell the IDE to use the directory /home/username/freepascal/fpc as FPC source directory.

If you have not yet downloaded the lazarus svn, do it now: Development versions from SVN. For example:

cd ~/freepascal
svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus

This will take some time, continue with:

cd ~/freepascal/lazarus
make clean all

If this gives linker errors, you have to install some packages (build-essential, libgtk2.0-dev,libgdk-pixbuf-dev). Start the IDE:

cd ~/freepascal/lazarus
./lazarus

This is a minimal IDE without any extra packages. Now the IDE must be setup and can be built with packages:

  • Go to Environment / Options / Environment
  • Set lazarus directory to /home/username/freepascal/lazarus
  • Set FPC source directory to /home/username/freepascal/fpc
  • Click Ok to close the dialog
  • Tools / Configure Build Lazarus / Quick Build Options / Build IDE with packages
  • Click Build.
  • Restart the IDE
  • Now you have the latest and greatest IDE built with the latest and greatest FPC.

Development versions from Git

There is a Git mirror of the official SubVersion repository being maintained on GitHub. This mirror gets sync'ed every 15 minutes with the SubVersion repository. For more information on getting Git and cloning the Lazarus repository, follow this link: Git Mirrors

Development versions from Mercurial

There is a Hg mirror of the official SubVersion repository being maintained on florianklaempfl.de.

Daily Snapshot method

If you don't want to use svn directly, you can try a daily snapshot. For a list of mirrors see the Lazarus Snapshots Downloads page.

Browse the Source Repository with a Web Browser

The contents of the SVN archive can also be browsed with your web-browser through this viewcvs interface.

Lazarus Distributions

There are some unofficial sites where you can find Lazarus and Free Pascal too:

  • You can get a Ubuntu LiveCD from Austrian University of Applied Sciences hosting

http://www.sigma-server.com/liveCD/Ubuntu-7.10-NTC-Lazarus.iso and md5sum file is here http://www.sigma-server.com/liveCD/Ubuntu-7.10-NTC-Lazarus.iso.md5.

Compiling and installing Lazarus

See Installing Lazarus - An installation guide.

Building from command-line

Lazarus is shipped with Makefile for gnu make util. (Be warn, if you're also have Codegear(or Borland) tools installed, it might conflict with gnu "make" util).

The tool allows you to compile the lazarus from command-line easily. You need to have fpc and fpc-packages installed and configured first.


To compile the goto Lazarus directory in your terminal and type

 make

This should rebuild LCL and Lazarus IDE (with basic packages installed).


Make targets

Following compiling targets can be specified for the make tool:

  • clean

The command will clean all compiled LCL and IDE units. Warning, this might make your project uncompilable (even though IDE still run, since binary is not deleted)

For example:

 make clean 
  • bigide - the command rebuilds LCL and IDE with additional packages.

For example:

 make bigide
  • lcl - the command rebuild LCL only. IDE is left untouched. The command is very useful if you're making changes to LCL and need to test the changes on your project without breaking Lazarus. Rebuild LCL only is faster than rebuilding both LCL and IDE

For example:

 make lcl
  • components
  • packager/registration
  • ideintf
  • packager
  • bigidecomponents
  • ide
  • idepkg
  • idebig
  • bigide
  • starter - the command rebuilds startlazarus binary.
  • lazbuilder
  • tools
  • all
  • cleanide
  • purge
  • examples - the command rebuilds examples lazarus
  • install
  • lazbuild


If no target is specified LCL and IDE Lazarus (with basic set of components) is rebuilt.

Make parameters

There're also additional parameters, can be used for 'making' Lazarus.

  • OPT=%compiler_switches

the %compiler_switches is passed to each fpc call. The option is useful for specifying defines

For example:

 make bigide OPT="-dNoGdkPixBufLib -gw2" 

makes LCL and ide with NoGdkPixBufLib defined and dwarf2 debug info.

  • LCL_PLATFORM=%platform

%platform is the target Widgetset. It can be win32,gtk,gtk2,qt,carbon or cocoa.

For example:

 make LCL_PLATFORM=gtk2

Rebuilds LCL and IDE for gtk2 widgetset

  • FPC=%compiler_path

%compiler_path is the path to a custom compiler binary you want to build the target with.

Original contributors and changes

This page has been converted from the epikwiki version.