Install fpc on Raspberry with Gentoo: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | *(Raspberry Pi only)* | |
| 2 | 2 | ||
| 3 | 3 | # Introduction | |
| 4 | 4 | ||
| 5 | 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 | 6 | ||
| 7 | 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 | 8 | ||
| 9 | 9 | # What kind of install? | |
| 10 | 10 | ||
| 11 | 11 | Below I describe the method I adopted to get a linux distro with these features: | |
| 12 | 12 | ||
| 13 | 13 | - Minimum linux installation | |
| 14 | 14 | - No X server, no desktop manager | |
| 15 | 15 | - Software installed: ssh, subversion and git | |
| 16 | 16 | - The latest stable version of the official fpc compiler (2.6.4) | |
| 17 | 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 | 18 | ||
| 19 | 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 | 20 | ||
| 21 | 21 | # Install the latest version of fpc from repository | |
| 22 | 22 | ||
| 23 | 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 | 24 | ||
| 25 | 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 | 26 | ||
| 27 | 27 | 1\) update the list of packages: | |
| 28 | 28 | ||
| 29 | - | ||
| 29 | + | ```text | |
| 30 | + | # emerge --sync | |
| 31 | + | ``` | |
| 30 | 32 | ||
| 31 | 33 | 2\) search for fpc compiler: | |
| 32 | 34 | ||
| 33 | - | ||
| 35 | + | ```text | |
| 36 | + | # emerge --search fpc | |
| 37 | + | ``` | |
| 34 | 38 | ||
| 35 | 39 | In case you find the correct version to compile the trunk (in this case 2.6.4), install it with no doubts: | |
| 36 | 40 | ||
| 37 | - | ||
| 41 | + | ```text | |
| 42 | + | # emerge dev-lang/fpc | |
| 43 | + | ``` | |
| 38 | 44 | ||
| 39 | 45 | and then jump to the section "Installation of subversion." | |
| 40 | 46 | ||
| 41 | 47 | In case there is not ... proceed manually according to the following section. | |
| 42 | 48 | ||
| 43 | 49 | # Manually install the latest version of fpc | |
| 44 | 50 | ||
| 45 | 51 | We must search for the arm fpc release. We have different places to search for, starting from following links: | |
| 46 | 52 | ||
| 47 | 53 | - <ftp://ftp.freepascal.org/pub/fpc/dist/2.6.4/arm-linux/> | |
| 48 | 54 | - <http://sourceforge.net/projects/freepascal/files/Linux/2.6.4/> | |
| 49 | 55 | ||
| 50 | 56 | Always verify both of them, they are not updated at the same time. | |
| 51 | 57 | ||
| 52 | 58 | Download the tarball and we can prepare to install (as root): | |
| 53 | 59 | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - | ||
| 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 | + | ``` | |
| 61 | 69 | ||
| 62 | 70 | 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 | 71 | ||
| 64 | 72 | - Installation folder : /usr/local | |
| 65 | 73 | - documentation not installed | |
| 66 | 74 | - examples not installed | |
| 67 | 75 | ||
| 68 | 76 | If you have installed in folder /usr/local, you can verify the presence of fpc : | |
| 69 | 77 | ||
| 70 | - | ||
| 78 | + | ```text | |
| 79 | + | # ls /usr/local/lib/fpc | |
| 80 | + | ``` | |
| 71 | 81 | ||
| 72 | 82 | and you will see its subfolders : | |
| 73 | 83 | ||
| 74 | 84 | - 2.6.4 | |
| 75 | 85 | - lexyacc | |
| 76 | 86 | ||
| 77 | 87 | Also try to run the compiler : | |
| 78 | 88 | ||
| 79 | - | ||
| 80 | - | ||
| 81 | - | ||
| 82 | - | ||
| 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 | + | ``` | |
| 83 | 95 | ||
| 84 | 96 | # Installing subversion | |
| 85 | 97 | ||
| 86 | 98 | 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 | 99 | ||
| 88 | - | ||
| 100 | + | ```text | |
| 101 | + | # emerge dev-vcs/subversion | |
| 102 | + | ``` | |
| 89 | 103 | ||
| 90 | 104 | On a raspberry with gentoo, emerge subversion is challenging process. It will take a while. | |
| 91 | 105 | ||
| 92 | 106 | # Downloading fpc trunk sources | |
| 93 | 107 | ||
| 94 | 108 | Now we need to download the sources of fpc trunk. | |
| 95 | 109 | ||
| 96 | - | ||
| 97 | - | ||
| 98 | - | ||
| 99 | - | ||
| 100 | - | ||
| 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 | + | ``` | |
| 101 | 117 | ||
| 102 | 118 | # Before building | |
| 103 | 119 | ||
| 104 | 120 | There are a few things to check: | |
| 105 | 121 | ||
| 106 | 122 | 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 | 123 | ||
| 108 | - | ||
| 109 | - | ||
| 124 | + | ```text | |
| 125 | + | # find /lib/ld-* | |
| 126 | + | /lib/ld-linux-armhf.so.3 | |
| 127 | + | ``` | |
| 110 | 128 | ||
| 111 | 129 | Remember this fullpath as we must pass it as a parameter. | |
| 112 | 130 | ||
| 113 | 131 | 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 | 132 | ||
| 115 | - | ||
| 116 | - | ||
| 133 | + | ```text | |
| 134 | + | # find /usr/lib -name crtbegin.o | |
| 135 | + | /usr/lib/gcc/armv6j-hardfloat-linux-gnueabi/4.7.3/crtbegin.o | |
| 136 | + | ``` | |
| 117 | 137 | ||
| 118 | 138 | Another fullpath to remember | |
| 119 | 139 | ||
| 120 | 140 | # Build the compiler | |
| 121 | 141 | ||
| 122 | 142 | Run the following commands in sequence: | |
| 123 | 143 | ||
| 124 | - | ||
| 125 | - | ||
| 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 | + | ``` | |
| 126 | 148 | ||
| 127 | 149 | here you have to wait a bit | |
| 128 | 150 | ||
| 129 | - | ||
| 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 | + | ``` | |
| 130 | 154 | ||
| 131 | 155 | 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 | 156 | ||
| 133 | 157 | We can instal sources | |
| 134 | 158 | ||
| 135 | - | ||
| 159 | + | ```text | |
| 160 | + | # make install sourceinstall PREFIX=/usr/local | |
| 161 | + | ``` | |
| 136 | 162 | ||
| 137 | 163 | 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 | 164 | ||
| 139 | - | ||
| 140 | - | ||
| 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 | + | ``` | |
| 141 | 169 | ||
| 142 | 170 | At this point I create a script to launch the new compiler passing the configuration file as parameter: | |
| 143 | 171 | ||
| 144 | - | ||
| 172 | + | ```text | |
| 173 | + | # nano /usr/local/bin/fpc271.sh | |
| 174 | + | ``` | |
| 145 | 175 | ||
| 146 | 176 | and there I copy the following content: | |
| 147 | 177 | ||
| 148 | - | ||
| 149 | - | ||
| 150 | - | ||
| 151 | - | ||
| 152 | - | ||
| 153 | - | ||
| 154 | - | ||
| 155 | - | ||
| 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 | + | ``` | |
| 156 | 188 | ||
| 157 | 189 | At this point, to compile with the 2.6.4 release, simply invoke compiler with the classic name fpc: | |
| 158 | 190 | ||
| 159 | - | ||
| 191 | + | ```text | |
| 192 | + | # fpc [options] | |
| 193 | + | ``` | |
| 160 | 194 | ||
| 161 | 195 | To invoke the 2.7.1 compiler: | |
| 162 | 196 | ||
| 163 | - | ||
| 197 | + | ```text | |
| 198 | + | # fpc271.sh [options] | |
| 199 | + | ``` | |
| 164 | 200 | ||
| 165 | 201 | --- | |
| 166 | 202 | *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 | 203 | Category: FPC | |
| 168 | 204 | Category: Install | |
| 169 | 205 | Category: Linux | |
| 170 | 206 | Category: Raspberry Pi |
