During the last year I discovered FPC and Lazarus and I am very impressed. However I have spent quite some time learning how to install them and setting them up in a way that is easily maintainable. Last time I had to do this I decided to document all the steps so I would remember what to do the next time. Hopefully someone else can find this useful too!
I have learnt most of these solutions from the lazarus web page, this forum and the email lists but I think it might be useful to collect everything in one place.
Note: This is only one way to do it. It seem to work nice for me, but there might be better ways to do it. If you have ideas for improvement feel free to add them to the thread.
I use this setup on my main computer: amd64 running kubuntu 8.04 64 bit
I tried to use it on my laptop: i386 running kubuntu 8.10. But there seem to be some issues with some changes to gtk that would require me to use a development version of fpc to compile the SVN version of lazarus. I didn't want to go into that at the moment so I decided that lazarus 0.9.26 was enough on the laptop.
This thread seems to describe the problem with the SVN version on Kubuntu 8.10:
http://forum.lazarus.freepascal.org/index.php/topic,5887.0.htmlInstalling FPCDownload the fpc binary and unpack it somewhere. I will use:
~/program/fpc-2.2.2Install it and let it put the binaries somewhere in your path. I will use ~/bin. If you do not have ~/bin in your path you might want to add it:
export PATH=$HOME/bin:$PATH(You can put this in your ~/.bashrc)
Check that fpc is found correctly by the shell by typing:
which fpcIt should show the path to where you just installed the fpc binaries
(~/bin).
The Lazarus IDE will also need the FPC source code so download that to and unpack it. I will use:
~/program/fpcsrc-2.2.2Installing LazarusThe following procedure installs two versions of lazarus, one stable version (0.9.26) and one SVN version. Two different profiles are used to avoid any potential problems coused by differences in the versions.
SVN versionMove to the location where you want to install lazarus (~/program). Checkout the latest Lazarus from svn into the lazarus-svn directory:
svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus-svnLater on you can update the lazarus svn directory with this comand:
svn updateTo build lazarus just move to the directory and type:
make clean allIf you got any errors see "Errors when building lazarus" below.
Verify that Lazarus works by starting it:
./lazarusIf everything went well Lazarus should now start. Most likely it will complain about not beeing able to find the fpc sources. Just ignore this for now and exit Lazarus.
Stable versionDownload the latest stable version (0.9.26) from the Lazarus website, and unpack it where you want to install it (~/program/lazarus-0.9.26).
To build lazarus just move to the directory and type:
make clean allIf you got any errors see "Errors when building lazarus" below.
Verify that this version of Lazarus works by starting it like you did
above.
Adding startup scriptsCreate the following files somewhere in your path (Ex: ~/bin). Modify the paths to where you installed lazarus.
lazarus-svn:
#/bin/sh
cd ~/program/lazarus-svn
./lazarus --primary-config-path=~/.lazarus-svn
lazarus-0.9.26:
#/bin/sh
cd ~/program/lazarus-0.9.26
./lazarus --primary-config-path=~/.lazarus-0.9.26
Make both scripts executable by typing:
chmod u+x lazarus-svn
chmod u+x lazarus-0.9.26Create a symbolic link to the version you wish to use as default. I use the SVN version:
ln -s lazarus-svn lazarusWhen you start lazarus with these scripts they will use two different profiles, stored in ~/.lazarus-svn and ~/.lazarus-0.9.26.
If you start lazarus the way you did before, by moving to the lazarus directory and just typing "./lazarus" the default profile directory (~/.lazarus) will be selected. But using the same profile with two versions of the same program could lead to troubles so it is a good idea to avoid this.
Test both scripts to see that they work correctly. When you start Lazarus it will still likely complain about that it can not find the FPC source directory. Correct this by going to Environment->Options->Files->FPC source directory and browse to the directory where you installed the FPC sources (~/program/fpcsrc-2.2.2).
Adding lazarus to the "start"-menuNow you can add an entry to the "Start" menu, or K menu or whatever it is called in your system.
Let the menu entry point to the symbolic link you just created (~/bin/lazarus), then the menu entry will always start the version you have selected as default.
If you look in the lazarus directory you can find a nice icon in images/ide_icon48x48.png that you can use for the menu entry.
Errors when building lazarusCommon errors when building lazarus is linking errors like:
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
lazarus.pp(124,1) Error: Error while linking
lazarus.pp(124,1) Fatal: There were 1 errors compiling module,In the case above the linker complains that it can not find "-lgdk_pixbuf-2.0". This actually means that it failed to find a file called libgdk_pixbuf-2.0.so somewhere in the library path. Usually the libraries are stored under /usr/lib/.
Let's have a look in /usr/lib/:
ls /usr/lib/libgdk_pixbuf-2.0*If this command finds no matching files, then the library is probably not installed at all.
If you find files that are very similar to the one you are looking for, like libgdk_pixbuf-2.0.so.0, then the library is installed, but you are missing the ".so" file the linker is looking for. This file is usually part of the development package for the library.
So to fix this problem, you should launch the package manager (adept, synaptic, rpmdrake etc) for your linux distriution and search for gdk_pixbuf. Install both the regular package and the development package. In this case I found two packages called libgdk_pixbuf2 and libgdk_pixbuf2-dev that should be installed.
If you have installed both packages and still don't get the ".so" file that the linker needs, then you can create this file manually. Just create a symbolic link like this:
sudo ln -s /usr/lib/libgdk_pixbuf-2.0.so.0 /usr/lib/libgdk_pixbuf-2.0.soAfter you have made sure that the linker will find the file it is looking for, try to build lazarus again:
make allThe
FAQ also have more useful information on these problems.
Thanks to Vincent who pointed out that the ".so" files usually are part of the dev package.