Sign in Join
Wiki copytemporary

Install fpc on Raspberry with Gentoo: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11*(Raspberry Pi only)*
22
33# Introduction
44
55This brief guide describes the steps I took to install the fpc free pascal compiler on my raspberry with gentoo. I could not find guides to install free pascal (not Lazarus) on a raspberry with gentoo, so, I want to share my experience. I followed several guides found on the net, especially this: <http://www.michellcomputing.co.uk/blog/2012/11/lazarus-on-the-raspberry-pi> I also searched (and found) help in both free pascal and gentoo forums and, in both cases, I received very valuable aid.
66
77If you are interested to the result, here you can find and download the SD image for your raspberry. <https://sourceforge.net/projects/pastoo/?source=navbar>
88
99# What kind of install?
1010
1111Below I describe the method I adopted to get a linux distro with these features:
1212
1313- Minimum linux installation
1414- No X server, no desktop manager
1515- Software installed: ssh, subversion and git
1616- The latest stable version of the official fpc compiler (2.6.4)
1717- additional and isolated (from the official 2.6.4) trunk fpc compiler (2.7.1) installed from source downloaded with subversion and compiled on raspberry.
1818
1919I chose the gentoo distro and, of course, the installation does not is the subject of this guide also because the official Gentoo documentation is very good.
2020
2121# Install the latest version of fpc from repository
2222
2323Whatever linux distro, it rarely happens the packages fpc/lazarus are aligned with the latest stable release. In my case, the last official fpc release is 2.6.4 (the only officially needed to compile the trunk), while in gentoo repositories I found fpc 2.6.2.
2424
2525I strongly recommend the use of official packages from the distro. Always check the repository for the release that you need, in the case of gentoo:
2626
27271\) update the list of packages:
2828
29-`   # emerge --sync `
29+```text
30+ # emerge --sync
31+```
3032
31332\) search for fpc compiler:
3234
33-`   # emerge --search fpc `
35+```text
36+ # emerge --search fpc
37+```
3438
3539In case you find the correct version to compile the trunk (in this case 2.6.4), install it with no doubts:
3640
37-`   # emerge dev-lang/fpc `
41+```text
42+ # emerge dev-lang/fpc
43+```
3844
3945and then jump to the section "Installation of subversion."
4046
4147In case there is not ... proceed manually according to the following section.
4248
4349# Manually install the latest version of fpc
4450
4551We must search for the arm fpc release. We have different places to search for, starting from following links:
4652
4753- <ftp://ftp.freepascal.org/pub/fpc/dist/2.6.4/arm-linux/>
4854- <http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/>
4955
5056Always verify both of them, they are not updated at the same time.
5157
5258Download the tarball and we can prepare to install (as root):
5359
54-`   # su`\
55-`   # mkdir /usr/local/fpc`\
56-`   # cd /usr/local/fpc`\
57-`   # wget -O fpc-2.6.4.arm-linux.tar `[`http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.arm-linux.tar/download`](http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.arm-linux.tar/download)\
58-`   # tar xvf fpc-2.6.4.arm-linux.tar`\
59-`   # cd fpc-2.6.4.arm-linux`\
60-`   # ./install.sh`
60+```text
61+ # su
62+ # mkdir /usr/local/fpc
63+ # cd /usr/local/fpc
64+ # wget -O fpc-2.6.4.arm-linux.tar http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/fpc-2.6.4.arm-linux.tar/download
65+ # tar xvf fpc-2.6.4.arm-linux.tar
66+ # cd fpc-2.6.4.arm-linux
67+ # ./install.sh
68+```
6169
6270You will be asked for some questions which usually we can answer pressing the ENTER key, howewer I have done the installation as follows:
6371
6472- Installation folder : /usr/local
6573- documentation not installed
6674- examples not installed
6775
6876If you have installed in folder /usr/local, you can verify the presence of fpc :
6977
70-`   # ls /usr/local/lib/fpc`
78+```text
79+ # ls /usr/local/lib/fpc
80+```
7181
7282and you will see its subfolders :
7383
7484- 2.6.4
7585- lexyacc
7686
7787Also try to run the compiler :
7888
79-`   # fpc`\
80-`   Free Pascal Compiler version 2.6.4 [2014/03/21] for arm`\
81-`   Copyright (c) 1993-2014 by Florian Klaempfl and others`\
82-`   /usr/local/lib/fpc/2.6.4/ppcarm...`
89+```text
90+ # fpc
91+ Free Pascal Compiler version 2.6.4 [2014/03/21] for arm
92+ Copyright (c) 1993-2014 by Florian Klaempfl and others
93+ /usr/local/lib/fpc/2.6.4/ppcarm...
94+```
8395
8496# Installing subversion
8597
8698Subversion is one of those programs that you will definitely find in the repository, whatever linux distro you have chosen. In the case of gentoo:
8799
88-`   # emerge dev-vcs/subversion`
100+```text
101+ # emerge dev-vcs/subversion
102+```
89103
90104On a raspberry with gentoo, emerge subversion is challenging process. It will take a while.
91105
92106# Downloading fpc trunk sources
93107
94108Now we need to download the sources of fpc trunk.
95109
96-`   # mkdir /usr/local/fpc/2.7.1`\
97-`   # cd /usr/local/fpc/2.7.1`\
98-`   # svn co `[`http://svn.freepascal.org/svn/fpc/trunk`](http://svn.freepascal.org/svn/fpc/trunk)` trunk`\
99-`   # svn export --force trunk trunktmp`\
100-`   # cd trunktmp`
110+```text
111+ # mkdir /usr/local/fpc/2.7.1
112+ # cd /usr/local/fpc/2.7.1
113+ # svn co http://svn.freepascal.org/svn/fpc/trunk trunk
114+ # svn export --force trunk trunktmp
115+ # cd trunktmp
116+```
101117
102118# Before building
103119
104120There are a few things to check:
105121
1061221\) ld-linux.so from the description in the man pages (man ld-linux.so): "The programs ld.so and ld-linux.so * find and load the shared libraries needed by a program, prepare the program to run, and then run it." You have to find this .so, whatever it's called and wherever it is located
107123
108-`   # find /lib/ld-*`\
109-`   /lib/ld-linux-armhf.so.3`
124+```text
125+ # find /lib/ld-*
126+ /lib/ld-linux-armhf.so.3
127+```
110128
111129Remember this fullpath as we must pass it as a parameter.
112130
1131312\) crtbegin.o and crtend.o These files are also needed to proceed with the construction of the compiler, so you have to find them; just look for one of the two:
114132
115-`   # find /usr/lib -name crtbegin.o         `\
116-`   /usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3/crtbegin.o`
133+```text
134+ # find /usr/lib -name crtbegin.o
135+ /usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3/crtbegin.o
136+```
117137
118138Another fullpath to remember
119139
120140# Build the compiler
121141
122142Run the following commands in sequence:
123143
124-`   # cd /usr/local/fpc/trunktmp`\
125-`   # make all OPT='-gl -O3p3' -j 8 FPMAKEOPT="-o -Fo/usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3" FPC=/usr/local/lib/fpc/2.6.4/ppcarm OPT=-FL/lib/ld-2.17.so OPT=-Fo/usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3`
144+```text
145+ # cd /usr/local/fpc/trunktmp
146+ # make all OPT='-gl -O3p3' -j 8 FPMAKEOPT="-o -Fo/usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3" FPC=/usr/local/lib/fpc/2.6.4/ppcarm OPT=-FL/lib/ld-2.17.so OPT=-Fo/usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3
147+```
126148
127149here you have to wait a bit
128150
129-`   # make install PP=compiler/ppcarm PREFIX=/usr/local -j 8 FPMAKEOPT="-o -Fo/usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3"`
151+```text
152+ # make install PP=compiler/ppcarm PREFIX=/usr/local -j 8 FPMAKEOPT="-o -Fo/usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3"
153+```
130154
131155Now, instead of creating a symbolic link in / usr / bin to be able to use the new compiler, I want to keep in use two compilers (such as mentioned at the beginning) and I want them isolated. This is why I do not create the link, but later, I will create a script.
132156
133157We can instal sources
134158
135-`   # make install sourceinstall PREFIX=/usr/local`
159+```text
160+ # make install sourceinstall PREFIX=/usr/local
161+```
136162
137163Now we need to create a configuration file so that it does not conflict with the one already present in /etc (related to the compiler 2.6.4). I want to place the fpc.cfg file in the “etc” subfolder inside the compiler folder. First of all, we can backup the files in /etc. Now we can create the etc subfolder:
138164
139-`   # mkdir /usr/local/lib/fpc/2.7.1/etc`\
140-`   # /usr/local/lib/fpc/2.7.1/samplecfg /usr/local/lib/fpc/2.7.1 /usr/local/lib/fpc/2.7.1/etc`
165+```text
166+ # mkdir /usr/local/lib/fpc/2.7.1/etc
167+ # /usr/local/lib/fpc/2.7.1/samplecfg /usr/local/lib/fpc/2.7.1 /usr/local/lib/fpc/2.7.1/etc
168+```
141169
142170At this point I create a script to launch the new compiler passing the configuration file as parameter:
143171
144-`   # nano /usr/local/bin/fpc271.sh `
172+```text
173+ # nano /usr/local/bin/fpc271.sh
174+```
145175
146176and there I copy the following content:
147177
148-`   #!/bin/sh`\
149-`   # This script execute the fpc trunk compiler `\
150-`   `\
151-`   if [ $# -eq 0 ]; then`\
152-`      /usr/local/lib/fpc/2.7.1/ppcarm`\
153-`   else`\
154-`      /usr/local/lib/fpc/2.7.1/ppcarm -n @/usr/local/lib/fpc/2.7.1/etc/fpc.cfg ""$@""`\
155-`   fi`
178+```text
179+ #!/bin/sh
180+ # This script execute the fpc trunk compiler
181+
182+ if [ $# -eq 0 ]; then
183+ /usr/local/lib/fpc/2.7.1/ppcarm
184+ else
185+ /usr/local/lib/fpc/2.7.1/ppcarm -n @/usr/local/lib/fpc/2.7.1/etc/fpc.cfg ""$@""
186+ fi
187+```
156188
157189At this point, to compile with the 2.6.4 release, simply invoke compiler with the classic name fpc:
158190
159-`   # fpc [options]`
191+```text
192+ # fpc [options]
193+```
160194
161195To invoke the 2.7.1 compiler:
162196
163-`   # fpc271.sh [options]`
197+```text
198+ # fpc271.sh [options]
199+```
164200
165201---
166202*From the Free Pascal wiki, page "Install fpc on Raspberry with Gentoo", as it stood on 2019-12-21 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
167203Category: FPC
168204Category: Install
169205Category: Linux
170206Category: Raspberry Pi

Back to history