Sign in Join
Wiki copytemporary

Install fpc on Raspberry with Gentoo: what changed

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

Title: Install fpc on Raspberry with Gentoo

OldNewLine
1+*(Raspberry Pi only)*
2+
3+# Introduction
4+
5+This 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.
6+
7+If 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>
8+
9+# What kind of install?
10+
11+Below I describe the method I adopted to get a linux distro with these features:
12+
13+- Minimum linux installation
14+- No X server, no desktop manager
15+- Software installed: ssh, subversion and git
16+- The latest stable version of the official fpc compiler (2.6.4)
17+- 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.
18+
19+I 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.
20+
21+# Install the latest version of fpc from repository
22+
23+Whatever 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.
24+
25+I 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:
26+
27+1\) update the list of packages:
28+
29+`   # emerge --sync `
30+
31+2\) search for fpc compiler:
32+
33+`   # emerge --search fpc `
34+
35+In case you find the correct version to compile the trunk (in this case 2.6.4), install it with no doubts:
36+
37+`   # emerge dev-lang/fpc `
38+
39+and then jump to the section "Installation of subversion."
40+
41+In case there is not ... proceed manually according to the following section.
42+
43+# Manually install the latest version of fpc
44+
45+We must search for the arm fpc release. We have different places to search for, starting from following links:
46+
47+- <ftp://ftp.freepascal.org/pub/fpc/dist/2.6.4/arm-linux/>
48+- <http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/>
49+
50+Always verify both of them, they are not updated at the same time.
51+
52+Download the tarball and we can prepare to install (as root):
53+
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`
61+
62+You will be asked for some questions which usually we can answer pressing the ENTER key, howewer I have done the installation as follows:
63+
64+- Installation folder : /usr/local
65+- documentation not installed
66+- examples not installed
67+
68+If you have installed in folder /usr/local, you can verify the presence of fpc :
69+
70+`   # ls /usr/local/lib/fpc`
71+
72+and you will see its subfolders :
73+
74+- 2.6.4
75+- lexyacc
76+
77+Also try to run the compiler :
78+
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...`
83+
84+# Installing subversion
85+
86+Subversion is one of those programs that you will definitely find in the repository, whatever linux distro you have chosen. In the case of gentoo:
87+
88+`   # emerge dev-vcs/subversion`
89+
90+On a raspberry with gentoo, emerge subversion is challenging process. It will take a while.
91+
92+# Downloading fpc trunk sources
93+
94+Now we need to download the sources of fpc trunk.
95+
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`
101+
102+# Before building
103+
104+There are a few things to check:
105+
106+1\) 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
107+
108+`   # find /lib/ld-*`\
109+`   /lib/ld-linux-armhf.so.3`
110+
111+Remember this fullpath as we must pass it as a parameter.
112+
113+2\) 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:
114+
115+`   # find /usr/lib -name crtbegin.o         `\
116+`   /usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3/crtbegin.o`
117+
118+Another fullpath to remember
119+
120+# Build the compiler
121+
122+Run the following commands in sequence:
123+
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`
126+
127+here you have to wait a bit
128+
129+`   # make install PP=compiler/ppcarm PREFIX=/usr/local -j 8 FPMAKEOPT="-o -Fo/usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3"`
130+
131+Now, 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.
132+
133+We can instal sources
134+
135+`   # make install sourceinstall PREFIX=/usr/local`
136+
137+Now 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:
138+
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`
141+
142+At this point I create a script to launch the new compiler passing the configuration file as parameter:
143+
144+`   # nano /usr/local/bin/fpc271.sh `
145+
146+and there I copy the following content:
147+
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`
156+
157+At this point, to compile with the 2.6.4 release, simply invoke compiler with the classic name fpc:
158+
159+`   # fpc [options]`
160+
161+To invoke the 2.7.1 compiler:
162+
163+`   # fpc271.sh [options]`
164+
165+---
166+*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).*
167+Category: FPC
168+Category: Install
169+Category: Linux
170+Category: Raspberry Pi

Back to history