Installing Lazarus on Linux

From Lazarus wiki
Jump to navigationJump to search

WARNING - This is a draft, a work in progress. Errors and Omissions Excepted (without a TRY statement !)

Introduction

This page is about installing FPC and Lazarus on a Linux system. Its intended for new and 'regular' users, it does not cover some very advanced methods. Linux users should think of FPC and Lazarus as being two distinct processes, FPC does not change much, on the other hand, you will probably want to update your Lazarus install or perhaps install multiple Lazarus versions. You can mix the install methods but only certain versions of FPC are suited to build or work with any particular version of Lazarus.

Notes about terms used on this page -

  • We refer to various downloadable files such as fpc_something - you will, hopefully obviously, replace the 'something' with whats appropriate for your system, early 2019 using a DEB based 64bit distro it might be fpc_3.0.4-3_amd64.deb for example.
  • Package Manager means a range of things on different different Linux systems. While we give command line examples, thats just because its easier to write. You will get the same result if you use your favourite GUI Tool such as Synaptic or Ubuntu Software Centre. Just make sure you are using a tool that resolves dependencies (that is, it also installs thing that are required by the main package you are installing). You should avoid using tools like dpkg or rpm and instead use apt, apt-get or yum depending on your flavour of Linux.

Installing FPC

Linux users have two main means of installing FPC, using your own package manager or using precompiled packages from SourceForge. The most important issue in deciding is which version of FPC do you want and can you get ?


FPC using Package Manager

Almost all Linux distributions come with some sort of Package Manager, you are probably familiar with your's. Between then DEB and RPM based package systems, represent much of the Linux community. Using your distro's package manager is probably the easiest and most dependable approach but first you must check the version of FPC your distribution is currently supplying.

Which version of FPC can I get ?

// DEB Users -
apt-get pkgnames fpc <enter>

// RPM User -

Note we need two packages, fpc-something and either fpc-src-something or fpc-source-something, note which and use it in the install instructions below. If you are happy with the offered version, install !

// DEB Users -
sudo apt install fpc <enter>
sudo apt install fpc-source <enter>

// RPM Users -
?

Note your package manager may later decide to update your version of FPC, maybe thats good but most users do not appreciate that happening. So, once installed, lock the version in your package manager, see XXX

FPC using SourceForge

If your Package Manager cannot offer you the correct version of FPC then SourceForge can !

All packages can be found at https://sourceforge.net/projects/lazarus/files/ , if you want just FPC, you will find it down in the corresponding Lazarus release directory.

Navigate down, select the appropriate packages, again, fpc_something and fpc-src_something, save them locally and install. WARNING, very important, this catches many users out ! Like most Linux packages, these packages have dependencies, you must install using a tool that resolves dependencies. Commands like "dpkg -i fpc_something.deb" will, most definitely leave an incomplete installation ! On a DEB based system, you probably should use gdebi instead.

Installing downloaded packages

// DEB Users -
sudo apt install gdebi <enter>
sudo gdebi [check syntax] fpc_something.deb <enter>
sudo gdebi [check syntax] fpc-src_something.deb <enter>

// RPM Users -
?

Testing FPC installation

OK, lets make a simple helloworld.pas, compile and test.

Installing Lazarus

Linux users have a choice of at least three models for installing Lazarus (once they have successfully installed and tested FPC). Again, using your Package Manager is a good choice if an appropriate version is available, downloading a package from SourceForge allows a wide choice of versions and, finally, you can build your own from source allowing a more flexible install. Please read carefully to unsure you get an install that suits your specific needs.


Lazarus using Package Manager.

Again the easiest model but as Lazarus changes more often then FPC, this may not be your best choice. Distros do have trouble keeping up with Lazarus releases and in many cases, it is useful to have the latest (stable) release. Further, Lazarus installed from packages end up in readonly (to the user) space, Lazarus is very good at managing that but it does complicate things a little (such as debug statements in the Lazarus Component Library). Further, you cannot have multiple package based installs, many users like to test new features and bug fixes. This model installs nice icons and menu items. If the negative things don't worry you, proceed to checking the available version and installing if you are happy.

Which version of Lazarus can I get ?

// DEB Users -
apt-cache pkgnames lazarus <enter>
// RPM User -
?

Installing Lazarus using Package Manager

// DEB Users -
sudo apt install lazarus_something.deb
     
// RPM Users -
?

You should now find a Lazarus entry in your menus system, start it up !


Lazarus from Source Forge

Almost as easy as above, has the advantage of a wide choice of versions. Will install icons and menu entries into your desktop. But still installed in readonly space and will only support one version of Lazarus. A great option form many users.

The FPC/Developers build precompiled packages in a number of formats for a number of platforms. There are production and release candidates, new users might be better of using production or, perhaps, later release candidates.

All packages can be found at https://sourceforge.net/projects/lazarus/files/

Navigate down, select the appropriate packages, lazarus-something, save locally and install. WARNING, very important, this catches many users out ! Like most Linux packages, these packages have dependencies, you must install using a tool that resolves dependencies. Commands like "dpkg -i lazarus_something.deb" will, most definitely leave an incomplete installation ! For example, on a DEB based system, you probably should use gdebi instead.

Installing downloaded Lazarus

// DEB Users (if you don't have gdebi already) -
sudo apt install gdebi <enter>
sudo gdebi [check syntax] lazarus_something <enter>

// RPM Users -

You should now find a Lazarus entry in your menus system, start it up !

Build Lazarus from Source

Surprising easy, but remember that Lazarus routinely rebuilds itself, eg when a Lazarus package is added. Also a useful test that all required dependencies are really present. Allows you to have multiple versions of Lazarus installed and both Lazarus and LCL are in your own diskspace so no write issues. However, you will need to manually add an entry in your OS Menu system and, perhaps distinctive Lazarus icons.

You will need the Subversion Package (for command 'svn') and, obviously, a fully installed and tested FPC along with FPC Source. The example here pulls down what is a good choice in early 2019, the fixes_2_0 branch of Lazarus. By time you read it, its likely a better option is available so please do your research. Note this is not a script, its a series of commands, to be copied one at a time, so you can see whats happening ! (Possible alternative branches might include "lazarus_1_8_4" and "trunk").

mkdir -p $HOME/bin/Lazarus
cd $HOME/bin/Lazarus
svn checkout https://svn.freepascal.org/svn/lazarus/branches/fixes_2_0
cd fixes_2_0
make clean
make bigide

You can now start Lazarus with the command ./lazarus or, if you are in another directory, something like -

/home/[your-user-name]/bin/Lazarus/fixes_2_0/lazarus <enter>

You can add that directory to your path, put a script in ~/bin to start it or whatever, its Linux, you choose !


Further Reading

Much discussion in a forum thread created by Handoko, https://forum.lazarus.freepascal.org/index.php/topic,41524.0.html This forum thread may be of particular interest to people who have upgraded an existing Linux install to a more recent version (ie Ubuntu 10.04 to 18.04) as that does seem to trigger some unexpected dependency problems. Please, ask for help, document such problems when you fix them.