Installing Lazarus on Linux
WARNING - This is a draft, a work in progress. Errors and Omissions Excepted (without a TRY statement !)
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 and concentrates on current releases. Linux users should think of FPC and Lazarus as being two distinct but related 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. Mixing the install methods, especially after V2.0 may cause problems so please read carefully.
Notes about terms used on this page -
- We refer to various downloadable files such as fpc_something - you should replace the 'something' with whats appropriate for your system, for example, early 2019 using a DEB based 64bit distro it might be fpc-laz_3.0.4-1_amd64.deb.
- 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, Ubuntu Software Centre or YaST2. Maybe try double clicking on a downloaded package in your file manager.
- What ever Package manager tool you use, make sure you are using one that resolves dependencies (that is, it also installs thing that are required by the main package you are installing), most GUI apps do. You should avoid using tools like dpkg or rpm and instead use apt, apt-get or yum depending on your flavour of Linux.
Make a Choice
You do need to decide, early on, where you will be getting your Lazarus install from. You can, at any stage change your mind but at the cost of some backtracking. We don't recomend you get your FPC and Lazarus install kits from different places, its sometimes possible but sometimes unreliable. Broadly, your choices are -
- Use your Package Manager to install both FPC and Lazarus. This means you are locked into the version of Lazarus that your distribution maintainers offer. Due to distro and Lazarus release cycles being out of sync, at any one time, its unlikely that your distribution will have the latest release of Lazarus. And many users do find those new releases attractive. You can install only one version of Lazarus under this model. But on the other hand, using the package manager approach is very easy and probably suits casual users.
- Use the pre compiled packages (both FPC and Lazarus) made available by the FPC/Lazarus Team at SourceForge. Here you will find a wide choice of matched versions but you can only install one version at a time. The install process is still very easy ! This is possibly the best bet for new users.
- Install FPC from either your Package Manager or SourceForge and then download the Lazarus source code and compile it yourself. May take a touch longer but is almost as easy and you do end up with the ability to add extra Lazarus installs, perhaps a 'production' version and a version based on the next release candidate. Or an old version to work on legacy code. In addition, you can easily make your own changes to the Lazarus Component Library, maybe just debug statements, maybe additional features you can feed back to help improve Lazarus further.
The Package Manager Model
If you are happy with the versions offered by your distribution this might be the way to go. Almost all Linux distributions come with some sort of Package Manager, you are probably familiar with your's. Between then, the DEB and RPM based package systems represent much of the Linux community. And if you soon run into the limitations of this model, your package manager will help you back out again. But first, check the version available. Look up 'lazarus' in your GUI Package Manager or do -
// DEB Users - apt-get pkgnames lazarus <enter> // RPM User - yum search lazarus <enter>
Note the names as well as the versions, we need three packages, fpc-something, fpc-source-something and, finally lazarus_something. Assuming you distribution's package has its dependencies set up correctly, all you need do is choose to install Lazarus in either your Package Manage GUI or do
// DEB Users - sudo apt-get install lazarus <enter> // RPM Users - sudo yum install lazarus <enter>
FPC and Lazarus from SourceForge
If your Package Manager cannot offer you the correct version of FPC then SourceForge can ! But be prepared for your package manager to complain about being bypassed, just insist you know what you are doing !
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, fpc-src_something and lazarus_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. On a DEB based system, you almost certainly should use gdebi to install any downloaded DEB. It might already be installed, if not, install it first. You can use gdebi at the command line or double click a downloaded package in your file manager. But remember, most important, install first fpc, then fpc-src, then and only then, Lazarus.
On an RPM Based System Installing downloaded packages at the command line as shown below. (Author is unaware of the GUI Package tool that does, in fact, resolve dependancies) -
// RPM Users - yum localinstall fpc_something.rpm <enter> yum localinstall fpc-src_something.rpm <enter> yum localinstall lazarus-something.rpm <enter>
Build Lazarus from Source
Surprising easy, but thats because Lazarus routinely rebuilds itself, eg when a Lazarus package is added. So, its also a useful test that all required dependencies are really present. Allows you to have multiple versions of Lazarus installed (see --pcp=xxx) 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.
Firstly, install (and test ?) FPC, you can use either of the above two models, but be careful to get a version that appropriate for your desired Lazarus.
Next, you will need Subversion (for command 'svn') to pull down the required version of Lazarus. The example here pulls down what is a good choice in early 2019, the newly released V2.0. By time you read this, its possible 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 !
mkdir -p $HOME/bin/Lazarus cd $HOME/bin/Lazarus svn checkout https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_0 cd lazarus_2_0_0 make clean make bigide
You can now start Lazarus with the command ./lazarus or, if you are in another directory, something like -
You can add that directory to your path, put a script in ~/bin to start it or whatever, its Linux, you choose !
Possible versions to bring down using SVN
- https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_0 - Released Feb, 2019, recommended.
- https://svn.freepascal.org/svn/lazarus/branches/fixes_2_0 - Reasonably stable but newer version of above
- https://svn.freepascal.org/svn/lazarus/tags/lazarus_1_8_4 - previous release, you are probably better off with 2.0
Testing FPC installation
While you can proceed directly to starting up Lazarus, if you have a problem, here is a simple test of half the system, FPC. We make a simple helloworld.pas, compile and test. Copy this very short program and save it as a file, helloworld.pas
program helloworld; begin writeln('hello world !'); end.
compile this code with this command line -
fpc helloworld.pas <enter>
It should very quickly make an executable called, you guessed it, "helloworld", Run this executable with this command -
If that worked, well done ! Now proceed to installing Lazarus.
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.