Recent

Author Topic: The way I setup lazarus and FPC on linux  (Read 54248 times)

nyrell

  • New Member
  • *
  • Posts: 14
    • http://nyrell.se
The way I setup lazarus and FPC on linux
« on: January 07, 2009, 07:37:41 pm »
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.html


Installing FPC
Download the fpc binary and unpack it somewhere. I will use:
~/program/fpc-2.2.2

Install 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 fpc

It 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.2


Installing Lazarus
The 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 version
Move 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-svn

Later on you can update the lazarus svn directory with this comand:
svn update

To build lazarus just move to the directory and type:
make clean all

If you got any errors see "Errors when building lazarus" below.

Verify that Lazarus works by starting it:
./lazarus

If 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 version
Download 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 all

If 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 scripts
Create the following files somewhere in your path (Ex: ~/bin). Modify the paths to where you installed lazarus.

lazarus-svn:
Code: [Select]
#/bin/sh
cd ~/program/lazarus-svn
./lazarus --primary-config-path=~/.lazarus-svn

lazarus-0.9.26:
Code: [Select]
#/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.26


Create a symbolic link to the version you wish to use as default. I use the SVN version:
ln -s lazarus-svn lazarus

When 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"-menu
Now 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 lazarus
Common 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.so

After you have made sure that the linker will find the file it is looking for, try to build lazarus again:
make all


The 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.
« Last Edit: January 09, 2009, 01:36:05 pm by nyrell »

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: The way I setup lazarus and FPC on linux
« Reply #1 on: January 07, 2009, 08:07:45 pm »
Nice article.

I have only one remark. The missing lib problem is usually fixed by installing the development package for the missing lib. See also FAQ.

nyrell

  • New Member
  • *
  • Posts: 14
    • http://nyrell.se
Re: The way I setup lazarus and FPC on linux
« Reply #2 on: January 07, 2009, 10:08:34 pm »
Nice article.

I have only one remark. The missing lib problem is usually fixed by installing the development package for the missing lib. See also FAQ.

Oh... That's good to know! I was not aware of that. Thanks!

Do you know if it is likely that there will be any problems if you manually create the link for the library file?
« Last Edit: January 07, 2009, 10:17:56 pm by nyrell »

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: The way I setup lazarus and FPC on linux
« Reply #3 on: January 07, 2009, 10:42:28 pm »
Do you know if it is likely that there will be any problems if you manually create the link for the library file?
No, I don't know. Maybe you run into trouble if you install that development package later on, or if it is removed or upgraded or whatever.

Sternas Stefanos

  • Full Member
  • ***
  • Posts: 167
  • Ex Pilot, M.Sc, Ph.D
    • http://www.pilotlogic.com
Re: The way I setup lazarus and FPC on linux
« Reply #4 on: January 08, 2009, 12:48:30 am »
CodeTyphon Architect and Programmer

nyrell

  • New Member
  • *
  • Posts: 14
    • http://nyrell.se
Re: The way I setup lazarus and FPC on linux
« Reply #5 on: January 09, 2009, 01:30:11 pm »
I modified my instructions and added the information about that the development packages contains the ".so" file. No need to manually create symbolic links in /usr/lib if it is not necessary!

mmm4m5m

  • Newbie
  • Posts: 1
Re: The way I setup lazarus and FPC on linux
« Reply #6 on: June 13, 2009, 02:41:16 pm »
Thank you. Very simple, very useful. I am new with linux/ubuntu. I read a lot - there are so many docs and talks about installation. It is ubuntu 8.04 and there is some issue with packages - installing lazarus does not install all required packages. Finally I choose to install it this way - simple and easy for upgrade. All is inside my home directory.

Notes about your description in case someone needs more details:
"download fp" - I downloaded "fpc-2.2.4.i386-linux.tar" - single archive and unpack it

"install fp" - I run install.sh, it ask for "install prefix", so I gave a path inside my home directory.

"which fpc" - This command: "PATH=$HOME/bin:$PATH which fpc" - It export PATH only for the next command. Almost the same like "export PATH..." and "which fpc".
You could get info about fpc with this command: "fpc -i".

"install lazarus" - After "make clean all" I decide to try "make clean all LCL_PLATFORM=gtk2" - it works, looks like I had all required packages

"run lazarus" - it ask for fpc sources - I downloaded "fpc-2.2.4.source.tar.gz" and unpack. Then click lazarus menu: environment/options/environment/FPC source directory and select.
From INSTALL.txt: <<The 'FPC Source directory' should point to your fpc source directory. This directory normally ends with /fpc/ or /fpcsrc/ (e.g. /usr/share/fpcsrc or /home/username/freepascal/fpc) and contains directories like 'compiler', 'docs', 'fcl', 'rtl' and 'packages'.>>

"Help for FPC keywords" - I downloaded "fpc-2.2.4-doc-html.tar.gz" and unpack. Then click lazarus menu: environment/options/help/help options/FPC Doc HTML Path (for v0.9.27 or help/configure help/general/fpc doc html path, for v0.9.26.2).
Check "Help for FPC keywords": http://wiki.freepascal.org/Creating_IDE_Help
« Last Edit: June 13, 2009, 06:06:20 pm by mmm4m5m »

invarbrass

  • New member
  • *
  • Posts: 8
Re: The way I setup lazarus and FPC on linux
« Reply #7 on: June 14, 2009, 01:20:27 pm »
Thank you. Very simple, very useful. I am new with linux/ubuntu. I read a lot - there are so many docs and talks about installation. It is ubuntu 8.04 and there is some issue with packages - installing lazarus does not install all required packages. Finally I choose to install it this way - simple and easy for upgrade. All is inside my home directory.
The lazarus source package in ubuntu repository has some issues. A lot of components refuse to compile.
Instead, install fpc 2.2.x from official ubuntu repo, but do not install lazarus.
Download lazarus source archive from this site, and build it yourself - it will compile perfectly.

icebit

  • New Member
  • *
  • Posts: 20
Re: The way I setup lazarus and FPC on linux
« Reply #8 on: June 30, 2009, 04:40:25 am »
Hello all,

I want to share with you how i installed lazarus on debian etch, manually.
Although i could used deb packages, i decided to install it manually, so the steps could be used in other linux flavor.

So this is the step-by-step:

1- Installed Debian with Desktop option.
2- Installed subversion through APT-GET.
3- Downloaded Lazarus svn to my Home directory with:
    svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus
4- Downloaded FPC binaries and source:
    fpc-2.2.4.i386-linux.tar
    fpc-2.2.4.source.tar.gz
5- Created diretory under lazarus for fpc and unziped fpc there:
    tar -xvf fpc-2.2.4.i386-linux.tar
    tar -zxvf fpc-2.2.4.source.tar.gz
6- export PATH=$HOME/lazarus/fpc-2.2.4/bin:$PATH
7- Checked with: which fpc    and    fpc -i
8- Installed libc-dev through APT-GET
9- Installed libgtk2.0-dev through APT-GET
10- After all, compiled lazarus with: make clean all LCL_PLATFORM=gtk2

Launched Lazarus and made configuration in menu environment->options->files and environment->options->debugger->general

Enjoy  :)


klacus

  • New Member
  • *
  • Posts: 20
Ubuntu 9.04
« Reply #9 on: August 31, 2009, 10:01:22 pm »
Install was verry simple on ubuntu 9.04.

1. Synaptic / FPC install

2. Only select the program container (Kpackagekit / Software handling), and push install button.... :-)

3 enjoy ..

egrobler

  • New Member
  • *
  • Posts: 17
Re: Ubuntu 9.04
« Reply #10 on: September 22, 2009, 09:37:03 pm »
Quote
Install was verry simple on ubuntu 9.04.
1. Synaptic / FPC install

Where do I download this?

Regards
Eric

egrobler

  • New Member
  • *
  • Posts: 17
Re: Ubuntu 9.04
« Reply #11 on: September 22, 2009, 10:08:05 pm »

Where do I download this?
[/quote]

I found it!
System > Administration > Synaptic in ubuntu
I then searched for Lazarus and "Applied" the changes.

Regards
Eric

danzman

  • New member
  • *
  • Posts: 6
Re: The way I setup lazarus and FPC on linux
« Reply #12 on: October 22, 2009, 12:56:57 am »
I am just getting my feet wet using Kubuntu. I need to install Lazarus/FreePascal the easiest way.  I am a newbie at this so bear with me. I need to translate some Delphi apps to run on linux.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 918
    • Burdjia
Re: The way I setup lazarus and FPC on linux
« Reply #14 on: October 23, 2009, 10:25:18 am »
What a nice information. :o Thanks man! I must try this. I just use Synaptic to install the packages on my Xubuntu system but I have some issues (i.e. can't use the latest versions of FPC or can't that or another library or package, etc.)
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal