Sign in Join
Wiki copytemporary

Installing the Free Pascal Compiler: what changed

Revision 3 to 4. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-While the Free Pascal Compiler comes pre-built for several processor architectures and operating systems, there may be occasions where a pre-built compiler won't do, and you need to build it yourself. There are a number of reasons for doing this, including:
1+While the Free Pascal Compiler comes pre-built for several processor architectures and operating systems, there may be occasions where a pre-built compiler won't do, and you need to build it yourself. There are a number of reasons for doing this, including:
22
3-- Intellectual curiosity - you want to discover the compiler's speed, using a medium sized application like the compiler itself.
4-- Cross Compiling - you want to build a compiler that creates binaries for a different CPU architecture, operating environment, or both, than the one you are using right now.
5-- New environment - you want to build the compiler for a processor or operating system that either a version of the compiler does not currently exist, or you are porting it to a new operating system or processor.
6-- Do it yourself - you prefer to build applications from source where possible.
7-- Security - for organizational policy, legal requirements, or operational security, programs from untrusted sources cannot be used, and must be recompiled locally. Or you want to confirm the compiler you have is the same as the one it produces, possibly running a checksum on the new one to confirm it matches the published one.
3+ * Intellectual curiosity - you want to discover the compiler's speed, using a medium sized application like the compiler itself.
4+ * Cross Compiling - you want to build a compiler that creates binaries for a different CPU architecture, operating environment, or both, than the one you are using right now.
5+ * New environment - you want to build the compiler for a processor or operating system that either a version of the compiler does not currently exist, or you are porting it to a new operating system or processor.
6+ * Do it yourself - you prefer to build applications from source where possible.
7+ * Security - for organizational policy, legal requirements, or operational security, programs from untrusted sources cannot be used, and must be recompiled locally. Or you want to confirm the compiler you have is the same as the one it produces, possibly running a checksum on the new one to confirm it matches the published one.
88
9-And the most obvious reason of all:
9+And the most obvious reason of all:
1010
11-- New Version - you are creating a new release of the compiler.
11+ * New Version - you are creating a new release of the compiler.
1212
13-This document will try to help you do these things.
13+This document will try to help you do these things.
1414
1515## Overview
1616
17-There are a number of ways to install the Free Pascal Compiler and its libraries on your system. The current version and trunk, and sometimes beta and release candidates, are available directly from the [FPC website](https://sourceforge.net/projects/freepascal/files/) (tar, exe, rpm, dmg, pkg files). In addition, versions of FPC are provided (including rpm and deb files) from the [Lazarus download site](http://sourceforge.net/projects/lazarus/files/). Linux users can almost certainly find FPC in their distribution's repositories but may find that it is outdated.
17+There are a number of ways to install the Free Pascal Compiler and its libraries on your system. The current version and trunk, and sometimes beta and release candidates, are available directly from the [FPC website](<https://sourceforge.net/projects/freepascal/files/>) (tar, exe, rpm, dmg, pkg files). In addition, versions of FPC are provided (including rpm and deb files) from the [Lazarus download site](<http://sourceforge.net/projects/lazarus/files/>). Linux users can almost certainly find FPC in their distribution's repositories but may find that it is outdated.
1818
19-It is possible to build FPC from source, typically each release needs to be built with the previous release. It is possible to install FPC in the application space (often requiring root or administrator access) or in a your own user space. These things depend on your particular operating system.
19+It is possible to build FPC from source, typically each release needs to be built with the previous release. It is possible to install FPC in the application space (often requiring root or administrator access) or in a your own user space. These things depend on your particular operating system.
2020
21-There is an extensive discussion of how to install and build Free Pascal compilers available here <http://www.stack.nl/~marcov/buildfaq.pdf> - it may be a little too detailed for some users, but it is very comprehensive.
21+There is an extensive discussion of how to install and build Free Pascal compilers available here <http://www.stack.nl/~marcov/buildfaq.pdf> \- it may be a little too detailed for some users, but it is very comprehensive.
2222
2323## Linux
2424
2525### Downloading FPC binary packages
2626
27-> **Note:** You have a number of way to install FPC presented here, which one is best for you depends very much on what you are planning to do and if you need a very current version. If you are also planning on installing Lazarus, perhaps a quick look at [[Installing Lazarus]] and [[Installing Lazarus on Linux]] is a very good idea.
28-
29-With the recent release of FPC 3.2.2, only a few distributions will have the new FPC compiler in its repositories. You can do one of -
27+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Note:** You have a number of way to install FPC presented here, which one is best for you depends very much on what you are planning to do and if you need a very current version. If you are also planning on installing Lazarus, perhaps a quick look at [[Installing Lazarus]] and [[Installing Lazarus on Linux]] is a very good idea.
3028
31-- If you use **rpm packages**, you can find FPC322 in <https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/> or more generally in <https://www.freepascal.org/download.html> You might install using a command like -
29+With the recent release of FPC 3.2.2, only a few distributions will have the new FPC compiler in its repositories. You can do one of -
3230
33-// or perhaps rpm -Uvh fpc-3.2.2-1.x86_64.rpm
31+ * If you use **rpm packages** , you can find FPC322 in <https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/> or more generally in <https://www.freepascal.org/download.html> You might install using a command like -
32+```
33+yum localinstall fpc-3.2.2-1.x86_64.rpm
34+ // or perhaps
35+ rpm -Uvh fpc-3.2.2-1.x86_64.rpm
36+```
3437
35-- If you use **deb packages** try the ones made available by, but not bundled with Lazarus at <https://sourceforge.net/projects/lazarus/files/>. Install using gdebi or, perhaps this command (note the ./ in front of filename, if you don't use an explicit path to filename, apt will search its own official repo, not what you want)-
36- ``` bash
37- apt install ./fpc-laz_3.2.2-1_amd64.deb
38- ```
38+ * If you use **deb packages** try the ones made available by, but not bundled with Lazarus at <https://sourceforge.net/projects/lazarus/files/>. Install using gdebi or, perhaps this command (note the ./ in front of filename, if you don't use an explicit path to filename, apt will search its own official repo, not what you want)-
39+```
40+apt install ./fpc-laz_3.2.2-1_amd64.deb
41+```
3942
40- Note the actual name changes from time to time, use the name you downloaded !
43+Note the actual name changes from time to time, use the name you downloaded !
4144
42-If you already have a FPC installed from your distro package manager, you should use that same package manager to remove them before installing under another model. Some quite strange things can happen if your compile uses a mixture of FPC versions !
45+If you already have a FPC installed from your distro package manager, you should use that same package manager to remove them before installing under another model. Some quite strange things can happen if your compile uses a mixture of FPC versions !
4346
4447### Downloading FPC tar balls
4548
46-Another option is installing from a tar, an easy and possibly even more useful model. These tars are available for a wide range of Unix like systems. You need to download the appropriate binary tar for your OS and CPU and you may also need the source files, common for all OS/CPU. You install FPC this way in your own space, not as root.
47-
48-Here is a series of commands, not a script, that will install FPC on a 64 bit Linux system. It could be scripted but would would need sanity and error checking. Note that I like to install things like this in my \$HOME/bin directory, if you prefer having it in \$HOME, it is even easier, I am sure you can see the differences.
49+Another option is installing from a tar, an easy and possibly even more useful model. These tars are available for a wide range of Unix like systems. You need to download the appropriate binary tar for your OS and CPU and you may also need the source files, common for all OS/CPU. You install FPC this way in your own space, not as root.
4950
50-> **Note:** A tar install **does not resolve dependencies**, if they are not already present, first install binutils, make, gcc.
51+Here is a series of commands, not a script, that will install FPC on a 64 bit Linux system. It could be scripted but would would need sanity and error checking. Note that I like to install things like this in my $HOME/bin directory, if you prefer having it in $HOME, it is even easier, I am sure you can see the differences.
5152
52-> **Note:** A tar ball install will, if you manage paths properly, allow you to have several versions of FPC installed.
53+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Note:** A tar install **does not resolve dependencies** , if they are not already present, first install binutils, make, gcc.
5354
54-(if you want something a bit newer, please see <https://www.freepascal.org/develop.html> )
55+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Note:** A tar ball install will, if you manage paths properly, allow you to have several versions of FPC installed.
5556
56-``` bash
57+(if you want something a bit newer, please see <https://www.freepascal.org/develop.html> )
58+```
5759cd
58-mkdir -p bin/FPC/Tars
59-mkdir bin/FPC/SRC
60-mkdir bin/FPC/fpc-3.2.2
61-cd bin/FPC/Tars
62-# download src and compiler tars, change for different CPU (or Mac ?)
63-
64-wget https://sourceforge.net/projects/freepascal/files/Source/3.2.2/fpc-3.2.2.source.tar.gz
65-wget https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/fpc-3.2.2.x86_64-linux.tar
66-
67-tar xf fpc-3.2.2.x86_64-linux.tar
68-cd fpc-3.2.2.x86_64-linux
69-./install.sh
70-# when asked where to install, enter $HOME/bin/FPC/fpc-3.2.2, accept all defaults after that.
71-
72-cd ../../SRC
73-tar xzf ../Tars/fpc-3.2.2.source.tar.gz
74-
75-# Set a path to where the compiler is, add line at end of .bashrc, if you don't use bash, adjust !
76-# (! e.g. Use ~/.profile instead of ~/.bashrc so that the path is available also in Lazarus IDE.)
77-echo "PATH=\"\$HOME/bin/FPC/fpc-3.2.2/bin\":\"\$PATH\"" >> ~/.bashrc
78-source ~/.bashrc
60+ mkdir -p bin/FPC/Tars
61+ mkdir bin/FPC/SRC
62+ mkdir bin/FPC/fpc-3.2.2
63+ cd bin/FPC/Tars
64+ # download src and compiler tars, change for different CPU (or Mac ?)
65+
66+ wget https://sourceforge.net/projects/freepascal/files/Source/3.2.2/fpc-3.2.2.source.tar.gz
67+ wget https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/fpc-3.2.2.x86_64-linux.tar
68+
69+ tar xf fpc-3.2.2.x86_64-linux.tar
70+ cd fpc-3.2.2.x86_64-linux
71+ ./install.sh
72+ # when asked where to install, enter $HOME/bin/FPC/fpc-3.2.2, accept all defaults after that.
73+
74+ cd ../../SRC
75+ tar xzf ../Tars/fpc-3.2.2.source.tar.gz
76+
77+ # Set a path to where the compiler is, add line at end of .bashrc, if you don't use bash, adjust !
78+ # (! e.g. Use ~/.profile instead of ~/.bashrc so that the path is available also in Lazarus IDE.)
79+ echo "PATH=\"\$HOME/bin/FPC/fpc-3.2.2/bin\":\"\$PATH\"" >> ~/.bashrc
80+ source ~/.bashrc
81+
82+ # trivial test
83+ cd
84+ fpc -iV
85+```
7986
80-# trivial test
81-cd
82-fpc -iV
87+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Note:** The second wget above assumes you are working with an amd64 (AMD or Intel) type machine, other platforms require a different tar ball. For example, for a **Raspberry Pi** , you would use -
8388```
89+wget https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/fpc-3.2.2.arm-linux.tar
90+```
8491
85-> **Note:** The second wget above assumes you are working with an amd64 (AMD or Intel) type machine, other platforms require a different tar ball. For example, for a **Raspberry Pi**, you would use -
86->
87-> ``` bash
88-> wget https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/fpc-3.2.2.arm-linux.tar
89-> ```
90->
91-> which has the armhf 32bit compiler. Incidentally, the Raspberry Pi may need you to increase swap space to at least a Gig if you plan to later build any large applications with FPC.
92+which has the armhf 32bit compiler. Incidentally, the Raspberry Pi may need you to increase swap space to at least a Gig if you plan to later build any large applications with FPC.
9293
9394### Downloading FPC sources from Git or zip
9495
95-If you plan to build your own compiler from source, this is the approach for you.
96-
97-The FPC source files are stored in a git repository (https://gitlab.com/freepascal.org/fpc/source). The repository keeps track of all the changes by developers in the source tree and has multiple branches. Once you have the sources, please see Installing from source under BSD/Linux for instructions on how to install them.
96+If you plan to build your own compiler from source, this is the approach for you.
9897
99-Anyone can download (but not upload) the source using either git or, easier if you want a one off snapshot, zip. And possibly even SVN. The default is to get the main (aka trunk) version of the source but you also select any one of the very many branches or tags.
98+The FPC source files are stored in a git repository (<https://gitlab.com/freepascal.org/fpc/source>). The repository keeps track of all the changes by developers in the source tree and has multiple branches. Once you have the sources, please see Installing from source under BSD/Linux for instructions on how to install them.
10099
101-**Git** - is most appropriate if you are going to add or sorrect something in the source and submit your change to the developers. Its a bigger and slower download but once done, easy to keep up to date. Note that its very unlikely contributions to anything other than main will be accepted. Here is an example initial download of main, assuming you already have git installed -
100+Anyone can download (but not upload) the source using either git or, easier if you want a one off snapshot, zip. And possibly even SVN. The default is to get the main (aka trunk) version of the source but you also select any one of the very many branches or tags.
102101
103-```text
104-git clone https://gitlab.com/freepascal.org/fpc/source
102+**Git** \- is most appropriate if you are going to add or sorrect something in the source and submit your change to the developers. Its a bigger and slower download but once done, easy to keep up to date. Note that its very unlikely contributions to anything other than main will be accepted. Here is an example initial download of main, assuming you already have git installed -
105103```
106-
107-Once the git download is finished, cd into the new directory and build as documented below. You can now keep your git repository up to date using the normal git commands. Git is well documented online but (https://wiki.freepascal.org/FPC_git) has some fpc specific help.
104+git clone <https://gitlab.com/freepascal.org/fpc/source>
105+```
108106
109-**Zip** - a possibly easier option is to download a "zip ball' archive of the source, from the web interface you can select which branch or tag you are interested in (combo box that defaults to 'main'). There are quite a lot of branches and tags to choose from, so please choose carefully. The web interface will let you download the zip of the selected branch or tag directly or command line people may do one of (with the last part of command line indicating which branch):
107+Once the git download is finished, cd into the new directory and build as documented below. You can now keep your git repository up to date using the normal git commands. Git is well documented online but (<https://wiki.freepascal.org/FPC_git>) has some fpc specific help.
110108
111-```text
112-wget https://gitlab.com/freepascal.org/fpc/source/-/archive/fixes_3_2/source-fixes_3_2.zip
113-wget https://gitlab.com/freepascal.org/fpc/source/-/archive/release_3_2_2/source-release_3_2_2.zip
109+**Zip** \- a possibly easier option is to download a "zip ball' archive of the source, from the web interface you can select which branch or tag you are interested in (combo box that defaults to 'main'). There are quite a lot of branches and tags to choose from, so please choose carefully. The web interface will let you download the zip of the selected branch or tag directly or command line people may do one of (with the last part of command line indicating which branch):
114110```
111+wget <https://gitlab.com/freepascal.org/fpc/source/-/archive/fixes_3_2/source-fixes_3_2.zip>
112+ wget <https://gitlab.com/freepascal.org/fpc/source/-/archive/release_3_2_2/source-release_3_2_2.zip>
113+```
115114
116-You would unzip the zipball and build the source as described below.
115+You would unzip the zipball and build the source as described below.
117116
118117#### Documentation sources
119118
120-The documentation sources are in a separate repository called fpcdocs, so the command to get them is:
121-
122-``` bash
119+The documentation sources are in a separate repository called fpcdocs, so the command to get them is:
120+```
123121cd ~
124-git clone https://gitlab.com/freepascal.org/fpc/documentation.git fpcdocs
122+ git clone https://gitlab.com/freepascal.org/fpc/documentation.git fpcdocs
125123```
126124
127-If you want to learn more about subversion, read this excellent [Subversion book](http://svnbook.red-bean.com/) which is also available online in different formats for free.
125+If you want to learn more about subversion, read this excellent [Subversion book](<http://svnbook.red-bean.com/>) which is also available online in different formats for free.
128126
129-For more information, see the [Free Pascal website](https://www.freepascal.org/develop.html).
127+For more information, see the [Free Pascal website](<https://www.freepascal.org/develop.html>).
130128
131129### Compiling the FPC source, using preinstalled FPC
132130
133-- First install the release FPC from RPM/DEB or tarballs as described above.
134-- Get FPC sources (trunk) as described above.
135-- Make FPC sources with (execute in the source (trunk) directory):
131+ * First install the release FPC from RPM/DEB or tarballs as described above.
132+ * Get FPC sources (trunk) as described above.
133+ * Make FPC sources with (execute in the source (trunk) directory):
136134
137-``` bash
135+```
138136make clean
139-make all
140-make install INSTALL_PREFIX=install/to/directory
137+ make all
138+ make install INSTALL_PREFIX=install/to/directory
141139```
142140
143-Decide about install/to/directory and also add options that you need.
141+Decide about install/to/directory (default one is /usr/local) and also add options that you need.
144142
145-- Check your ~/.fpc.cfg or /etc/fpc.cfg. It either has to be valid for the trunk compiler as well or you have to move it to the ../etc directory above your compiler executable. E.g. if your compiler is in ~/software/fpc/3.2.0/lib/fpc/3.2.0 (~/software/fpc/3.2.0/bin), you have to move the fpc.cfg to ~/software/fpc/3.2.0/lib/fpc/etc.
146-- If you have no valid global fpc.cfg file, you have to create one in install/to/directory/lib/fpc/etc. For this run the following commands
143+ * Check your ~/.fpc.cfg or /etc/fpc.cfg. It either has to be valid for the trunk compiler as well or you have to move it to the ../etc directory above your compiler executable. E.g. if your compiler is in ~/software/fpc/3.2.0/lib/fpc/3.2.0 (~/software/fpc/3.2.0/bin), you have to move the fpc.cfg to ~/software/fpc/3.2.0/lib/fpc/etc.
144+ * If you have no valid global fpc.cfg file, you have to create one in install/to/directory/lib/fpc/etc. For this run the following commands
147145
148-``` bash
146+```
149147cd install/to/directory/lib/fpc
150-mkdir etc
151-fpcmkcfg -d basepath="install/to/directory/lib/fpc/\$fpcversion" -o etc/fpc.cfg
148+ mkdir etc
149+ fpcmkcfg -d basepath="install/to/directory/lib/fpc/\$fpcversion" -o etc/fpc.cfg
152150```
153151
152+Uninstall (assuming default INSTALL_PREFIX is used):
153+```
154+sudo rm -rf /usr/local/bin/fp*
155+ sudo rm -rf /usr/local/bin/pas2fpm
156+ sudo rm -rf /usr/local/bin/instantfpc
157+ sudo rm -rf /usr/local/lib/fpc
158+ sudo rm -rf /usr/local/share/doc/fpc*
159+ sudo rm -rf /usr/local/lib/*/fpc
160+```
161+
154162### Compiling the FPC source, using just downloaded FPC 3.2.2
155163
156-- Download FPC 3.2.2 (latest official release), ie tarball fpc-3.2.2.x86_64-linux.tar.
157-- Unpack this tarball to e.g. "~/Downloads/fpc", do CD to the folder containing the file "install.sh", run from Terminal:
164+ * Download FPC 3.2.2 (latest official release), ie tarball fpc-3.2.2.x86_64-linux.tar.
165+ * Unpack this tarball to e.g. "~/Downloads/fpc", do CD to the folder containing the file "install.sh", run from Terminal:
158166
159-```text
167+```
160168$ ./install.sh
161169```
162170
163-It will ask several questions in the Terminal, answer them. You will have installed FPC 3.2.2 to the folder e.g. "/home/user/fpc-3.2.2".
171+It will ask several questions in the Terminal, answer them. You will have installed FPC 3.2.2 to the folder e.g. "/home/user/fpc-3.2.2".
164172
165-- Download the Git snapshot of FPC:
173+ * Download the Git snapshot of FPC:
166174
167-```text
168-$ git clone https://gitlab.com/freepascal.org/fpc/source
169175```
176+$ git clone <https://gitlab.com/freepascal.org/fpc/source>
177+```
170178
171-- Do CD to new folder "source" and call:
179+ * Do CD to new folder "source" and call:
172180
173-```text
181+```
174182$ make clean PP=/home/user/fpc-3.2.2/bin/fpc
175-$ make all PP=/home/user/fpc-3.2.2/bin/fpc
183+ $ make all PP=/home/user/fpc-3.2.2/bin/fpc
176184```
177185
178-Here you must specify the "PP=" key and the full path to the "fpc" file installed from tarball. Command "make clean" is required if you **compile again**.
186+Here you must specify the "PP=" key and the full path to the "fpc" file installed from tarball. Command "make clean" is required if you **compile again**.
179187
180-Final compiled binary will be the file "source/compiler/ppcx64".
188+Final compiled binary will be the file "source/compiler/ppcx64".
181189
182190## FreeBSD
183191
184-> **Note:** If you wish to also install Lazarus, you can omit installing FPC with the steps below as the Lazarus port will install it for you. See [[Installing Lazarus on FreeBSD]].
192+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Note:** If you wish to also install Lazarus, you can omit installing FPC with the steps below as the Lazarus port will install it for you. See [[Installing Lazarus on FreeBSD]].
185193
186194### Installing from the ports collection
187195
188-The FreeBSD ports collection has FPC v3.2.2 version in `/usr/ports/lang/fpc` and FPC Development v3.3.1 version in `/usr/ports/lang/fpc-devel`. Nowadays all units were merged into only one package of FPC/FPC-devel. The FPC/FPC-devel source is now installed by default; it previously needed to be copied and uncompressed from `/usr/ports/distfiles/freepascal`.
189-
190-This must be done as root.
196+The FreeBSD ports collection has FPC v3.2.3 version in `/usr/ports/lang/fpc` and FPC Development v3.3.1 version in `/usr/ports/lang/fpc-devel`. Nowadays all units were merged into only one package of FPC/FPC-devel. The FPC/FPC-devel source is now installed by default; it previously needed to be copied and uncompressed from `/usr/ports/distfiles/freepascal`.
191197
192-``` bash
198+This must be done as root.
199+```
193200# cd /usr/ports/lang/fpc && make install && make clean
194201```
195202
196-If you want use development (aka trunk) version of fpc with all units included do the following:
197-
198-``` bash
203+If you want use development (aka trunk) version of fpc with all units included do the following:
204+```
199205# cd /usr/ports/lang/fpc-devel && make install clean
200206```
201207
202-Also, you can install FPC and units from pkg binaries:
203-
204-``` bash
208+Also, you can install FPC and units from pkg binaries:
209+```
205210# pkg install lang/fpc
206211```
207212
208-Installing development FPC and units from pkg binaries:
209-
210-``` bash
213+Installing development FPC and units from pkg binaries:
214+```
211215# pkg install lang/fpc-devel
212216```
213217
214-Once FPC is installed you can check if it's working by simply running as a normal user:
215-
216-``` bash
218+Once FPC is installed you can check if it's working by simply running as a normal user:
219+```
217220$ fpc test
218221```
219222
220-which should produce output similar to this:
221-
222-```text
223- Free Pascal Compiler version 3.2.2 [2021/08/03] for x86_64
224- Copyright (c) 1993-2021 by Florian Klaempfl and others
225- Target OS: FreeBSD for x86-64
226- Compiling test
227- Fatal: Cannot open file "test"
228- Fatal: Compilation aborted
229- Error: /usr/local/bin/ppcx64 returned an error exitcode
223+which should produce output similar to this:
230224```
225+Free Pascal Compiler version 3.2.3 [2024/06/17] for x86_64
226+ Copyright (c) 1993-2024 by Florian Klaempfl and others
227+ Target OS: FreeBSD for x86-64
228+ Compiling test
229+ Fatal: Cannot open file "test"
230+ Fatal: Compilation aborted
231+ Error: /usr/local/bin/ppcx64 returned an error exitcode
232+```
231233
232234### Installing from tar
233235
234-Select the appropriate 32 bit/64 bit tar file based on your system. For x86_64 64-bit FreeBSD, download from [x86_64](https://www.freepascal.org/down/x86_64/freebsd.html). For i386 32-bit FreeBSD, download from [i386](https://www.freepascal.org/down/i386/freebsd.html).
235-
236-To install Free Pascal from a terminal:
236+Select the appropriate 32 bit/64 bit tar file based on your system. For x86_64 64-bit FreeBSD, download from [x86_64](<https://www.freepascal.org/down/x86_64/freebsd.html>). For i386 32-bit FreeBSD, download from [i386](<https://www.freepascal.org/down/i386/freebsd.html>).
237237
238-``` bash
238+To install Free Pascal from a terminal:
239+```
239240$ fetch ftp://ftp.freepascal.org/pub/fpc/dist/3.2.2/x86_64-freebsd/fpc-3.2.2.x86_64-freebsd11.tar
240-$ tar -xf fpc-3.2.2.x86_64-freebsd11.tar
241-$ cd fpc-3.2.2.x86_64-freebsd
242-$ bash install.sh
241+ $ tar -xf fpc-3.2.2.x86_64-freebsd11.tar
242+ $ cd fpc-3.2.2.x86_64-freebsd
243+ $ bash install.sh
243244```
244245
245-Replace the desired Free Pascal version (3.0.4, 3.2.0 or 3.2.2) and architecture (x86_64 or i386) as required.
246-
247-If you want to install the Free Pascal Compiler globally, for example in `/usr/local`, run the install.sh script as root. `install.sh` script uses bash shell syntax. If you get `Bad substitution` error, make sure you run script with bash.
246+Replace the desired Free Pascal version (3.0.4, 3.2.0 or 3.2.2) and architecture (x86_64 or i386) as required.
248247
249-If you are on FreeBSD 12 or newer, the default linker is the `lld`. This may cause problems if you have code that uses, for example, the *cthreads* unit as in the following program:
248+If you want to install the Free Pascal Compiler globally, for example in `/usr/local`, run the install.sh script as root. `install.sh` script uses bash shell syntax. If you get `Bad substitution` error, make sure you run script with bash.
250249
251-``` pascal
250+If you are on FreeBSD 12 or newer, the default linker is the `lld`. This may cause problems if you have code that uses, for example, the _cthreads_ unit as in the following program:
251+```
252252uses cthreads;
253-begin
254- writeln('hello');
255-end.
253+ begin
254+ writeln('hello');
255+ end.
256256```
257257
258-The executable generated for this program will cause a segmentation fault when run. To fix this issue, you need to install the GNU linker:
259-
260-``` bash
258+The executable generated for this program will cause a segmentation fault when run. To fix this issue, you need to install the GNU linker:
259+```
261260root# pkg install binutils
262261```
263262
264-and add a symbolic-link from `/usr/local/bin/ld.bfd` to `/bin/ld.bfd`.
263+and add a symbolic-link from `/usr/local/bin/ld.bfd` to `/bin/ld.bfd`.
265264
266265## OpenBSD
267266
268267### Installing from tar
269268
270-Select the appropriate 32 bit/64 bit tar file based on your system. For x86_64 64-bit OpenBSD, download from [x86_64](https://sourceforge.net/projects/freepascal/files/OpenBSD/3.2.2/fpc-3.2.2.x86_64-openbsd.tar). For i386 32-bit OpenBSD, download from [i386](https://sourceforge.net/projects/freepascal/files/OpenBSD/3.2.2/fpc-3.2.2.i386-openbsd.tar).
271-
272-To install Free Pascal from a terminal:
269+Select the appropriate 32 bit/64 bit tar file based on your system. For x86_64 64-bit OpenBSD, download from [x86_64](<https://sourceforge.net/projects/freepascal/files/OpenBSD/3.2.2/fpc-3.2.2.x86_64-openbsd.tar>). For i386 32-bit OpenBSD, download from [i386](<https://sourceforge.net/projects/freepascal/files/OpenBSD/3.2.2/fpc-3.2.2.i386-openbsd.tar>).
273270
274-``` bash
271+To install Free Pascal from a terminal:
272+```
275273$ wget https://sourceforge.net/projects/freepascal/files/OpenBSD/3.2.2/fpc-3.2.2.x86_64-openbsd.tar
276-$ tar -xf fpc-3.2.2.x86_64-openbsd.tar
277-$ cd fpc-3.2.2.x86_64-openbsd
278-$ bash install.sh
274+ $ tar -xf fpc-3.2.2.x86_64-openbsd.tar
275+ $ cd fpc-3.2.2.x86_64-openbsd
276+ $ bash install.sh
279277```
280278
281-Replace the desired Free Pascal version (3.0.4, 3.2.0, or 3.2.2) and architecture (x86_64 or i386) as required.
279+Replace the desired Free Pascal version (3.0.4, 3.2.0, or 3.2.2) and architecture (x86_64 or i386) as required.
282280
283-If you want to install the Free Pascal Compiler globally, for example in `/usr/local`, run the install.sh script as root. `install.sh` script uses bash shell syntax. If you get `Bad subtitution` error, make sure you run script with bash. OpenBSD uses ksh as default shell. You need to install bash manually.
281+If you want to install the Free Pascal Compiler globally, for example in `/usr/local`, run the install.sh script as root. `install.sh` script uses bash shell syntax. If you get `Bad subtitution` error, make sure you run script with bash. OpenBSD uses ksh as default shell. You need to install bash manually.
284282
285283## Installing from source on BSD/Linux
286284
287-Effectively, you need:
285+Effectively, you need:
288286
289-1\. A file with all FPC sources downloaded from git (https://gitlab.com/freepascal.org/fpc/source) or perhaps (https://sourceforge.net/projects/freepascal/files/Source/3.2.2/fpc-3.2.2.source.tar.gz).
287+1\. A file with all FPC sources downloaded from git (<https://gitlab.com/freepascal.org/fpc/source>) or perhaps (<https://sourceforge.net/projects/freepascal/files/Source/3.2.2/fpc-3.2.2.source.tar.gz>).
290288
291-2\. A starting (bootstrap) FPC compiler. An FPC release can always be built by the previously released FPC version, and FPC trunk can always be built by the current FPC release. You can download a bootstrap Free Pascal Compiler or use your distribution's package management/software system to install one.
289+2\. A starting (bootstrap) FPC compiler. An FPC release can always be built by the previously released FPC version, and FPC trunk can always be built by the current FPC release. You can download a bootstrap Free Pascal Compiler or use your distribution's package management/software system to install one.
292290
293-FPC build process:
291+FPC build process:
294292
295-- Fetch necessary files (starting compiler), FPC source file or source svn directory
296-- If using FPC source files: extract/de-tgz in work directory,
297-- Build: enter work/fpc/ and run:
293+ * Fetch necessary files (starting compiler), FPC source file or source svn directory
294+ * If using FPC source files: extract/de-tgz in work directory,
295+ * Build: enter work/fpc/ and run:
298296
299-``` bash
297+```
300298# Linux use:
301-export MAKE=`which make` ; echo $MAKE
302-# FreeBSD use (default csh, or tcsh):
303-set MAKE=`which gmake` ; echo $MAKE
304-# FreeBSD use (bash):
305-export MAKE=`which gmake` ; echo $MAKE
306-$MAKE all OPT='-gl' FPC=/path/to/startingcompiler-name-ppcx64
307-# $MAKE is make on Linux and gmake on BSD
308-# /path/to/ can be omitted when ppc386 (32 bit) or ppcx64 (64 bit) is in the path
299+ export MAKE=`which make` ; echo $MAKE
300+ # FreeBSD use (default csh, or tcsh):
301+ set MAKE=`which gmake` ; echo $MAKE
302+ # FreeBSD use (bash):
303+ export MAKE=`which gmake` ; echo $MAKE
304+ $MAKE all OPT='-gl' FPC=/path/to/startingcompiler-name-ppcx64
305+ # $MAKE is make on Linux and gmake on BSD
306+ # /path/to/ can be omitted when ppc386 (32 bit) or ppcx64 (64 bit) is in the path
309307```
310308
311-- Install FPC. Again in work/fpc, run
309+ * Install FPC. Again in work/fpc, run
312310
313-``` bash
311+```
314312$MAKE install FPC=compiler/ppcx64 PREFIX=$THEPREFIX
315-#replace the FPC=compiler/ppcx64 (or ppc386 for 32 bit) with the relevant compiler if not on Intel x86
316-#THEPREFIX= usually is /usr/local or just /usr, but eg on NetBSD it is /usr/pkg for ports)
313+ #replace the FPC=compiler/ppcx64 (or ppc386 for 32 bit) with the relevant compiler if not on Intel x86
314+ #THEPREFIX= usually is /usr/local or just /usr, but eg on NetBSD it is /usr/pkg for ports)
317315```
318316
319-- Create a symlink:
317+ * Create a symlink:
320318
321-``` bash
319+```
322320ln -s $THEPREFIX/lib/fpc/3.2.2/ppcx64 $THEPREFIX/bin/ppcx64
323321```
324322
325-- Install sources:
323+ * Install sources:
326324
327-``` bash
325+```
328326$MAKE install sourceinstall PREFIX=$THEPREFIX
329327```
330328
331-- Create a symlink for default FPC source path:
329+ * Create a symlink for default FPC source path:
332330
333-``` bash
331+```
334332ln -sf $THEPREFIX/share/src/3.2.2/fpc /usr/share/fpcsrc
335333```
336334
337-- Set up fpc.cfg configuration file:
335+ * Set up fpc.cfg configuration file:
338336
339-``` bash
337+```
340338$THEPREFIX/lib/fpc/3.2.2/samplecfg $THEPREFIX/lib/fpc/3.2.0 $ETCDIR
341339```
342340
343-- Optionally test to see if `ppcx64 -i` (or whatever compiler your architecture uses) gives output, else give a warning that user needs to add \$PREFIX/bin to the current path. Try to compile a program with `ppcx64 -viwn`, and see if that gives errors.
341+ * Optionally test to see if `ppcx64 -i` (or whatever compiler your architecture uses) gives output, else give a warning that user needs to add $PREFIX/bin to the current path. Try to compile a program with `ppcx64 -viwn`, and see if that gives errors.
344342
345-Notes:
343+Notes:
346344
347-- If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with
348- ``` bash
349- find . >ll
350- ```
345+ * If you need fpcmake package lists, you need to generate or supply them yourself, (in the port, or in an extra archive) either way, do a dummy install to /tmp/pack and determine the files installed with
346+```
347+find . >ll
348+```
351349
352-- \$THEPREFIX and \$ETCDIR should be user configurable. Otherwise local installs aren't possible.
350+ * $THEPREFIX and $ETCDIR should be user configurable. Otherwise local installs aren't possible.
353351
354-- BSDHIER=1 on all make commands forces BSD hierarchy conventions.
352+ * BSDHIER=1 on all make commands forces BSD hierarchy conventions.
355353
356354## Windows
357355
358356### Installing an FPC release with the Windows installer
359357
360-> **Warning:** If you are intending to also install Lazarus using the official Windows installer which installs both FPC + Lazarus, please ignore these instructions and instead refer to [[Installing Lazarus on Windows]] to avoid having to resolve any resulting conflicts.
358+[![Warning-icon.png](/wiki-images/b/b2/Warning-icon.png)](</File:Warning-icon.png>)
361359
362-By far the easiest way to get a working installation of the Free Pascal Compiler is to download and run the appropriate self-extracting Windows installer from the official [SourceForge repository for FPC 3.2.2](https://sourceforge.net/projects/freepascal/files/Win32/3.2.2/) - this release contains the current release versions of the Free Pascal Compiler and the Free Pascal libraries. The Windows installer packages install very easily, and should work 'out-of-the-box'. You will be taken through a typical Windows installation wizard to install the FPC binaries and Free Pascal libraries:
360+**Warning:** If you are intending to also install Lazarus using the official Windows installer which installs both FPC + Lazarus, please ignore these instructions and instead refer to [[Installing Lazarus on Windows]] to avoid having to resolve any resulting conflicts.
363361
364-- Choose an installation location for FPC (suggested `C:\FPC\3.2.2`)
365-- Choose installation type (recommended Full Installation)
366-- Choose file associations, configuration file creation etc
367-- Install
368-- View README
362+By far the easiest way to get a working installation of the Free Pascal Compiler is to download and run the appropriate self-extracting Windows installer from the official [SourceForge repository for FPC 3.2.2](<https://sourceforge.net/projects/freepascal/files/Win32/3.2.2/>) \- this release contains the current release versions of the Free Pascal Compiler and the Free Pascal libraries. The Windows installer packages install very easily, and should work 'out-of-the-box'. You will be taken through a typical Windows installation wizard to install the FPC binaries and Free Pascal libraries:
369363
364+ * Choose an installation location for FPC (suggested `C:\FPC\3.2.2`)
365+ * Choose installation type (recommended Full Installation)
366+ * Choose file associations, configuration file creation etc
367+ * Install
368+ * View README
369+
370370### Installing from source
371371
372-Installing from source with a command line git client is not for novices, since you also need a working bootstrap compiler to be able to compile the Free Pascal Compiler from source. Instructions for obtaining a bootstrap compiler are included below.
372+Installing from source with a command line git client is not for novices, since you also need a working bootstrap compiler to be able to compile the Free Pascal Compiler from source. Instructions for obtaining a bootstrap compiler are included below.
373373
374374#### Obtaining the source with a command line git client
375375
376-The easiest way to get the Free Pascal Compiler source is by using a git client. The exact commands may vary between git clients; the commands given below are for the command line git client downloadable from [GitForWindows.org](https://gitforwindows.org/).
376+The easiest way to get the Free Pascal Compiler source is by using a git client. The exact commands may vary between git clients; the commands given below are for the command line git client downloadable from [GitForWindows.org](<https://gitforwindows.org/>).
377377
378378##### Source for a release version of FPC
379379
380-First create a directory in which you'd like to keep the source. Any normal user can do this. Create a directory for FPC (eg `C:\Source`) by typing the following at a command prompt:
381-
382-```dos
380+First create a directory in which you'd like to keep the source. Any normal user can do this. Create a directory for FPC (eg `C:\Source`) by typing the following at a command prompt:
381+```
383382C:\Users\you> cd \
384-C:\> mkdir Source
385-C:\> cd Source
383+ C:\> mkdir Source
384+ C:\> cd Source
386385```
387386
388-Now type issue the following command at a command prompt:
389-
390-```dos
387+Now type issue the following command at a command prompt:
388+```
391389C:\Source> git clone -b release_3_2_2 https://gitlab.com/freepascal.org/fpc/source.git fpc-3.2.2
392390```
393391
394-Wait while the git repository is downloaded to the fpc-3.2.2 directory in your newly created Source directory. This can take a while... have a look at the helpful [Free Pascal Forums](https://forum.lazarus.freepascal.org/) while you wait :-) You may also like to read the excellent [[Forum|How to use the Forum]] Wiki article which explains how to get answers to pesky questions quickly. New Forum users are always welcome.
392+Wait while the git repository is downloaded to the fpc-3.2.2 directory in your newly created Source directory. This can take a while... have a look at the helpful [Free Pascal Forums](<https://forum.lazarus.freepascal.org/>) while you wait :-) You may also like to read the excellent [[Forum|How to use the Forum]] Wiki article which explains how to get answers to pesky questions quickly. New Forum users are always welcome.
395393
396394##### Source for a non-release version of FPC
397395
398-There are two current non-release branches of the Free Pascal Compiler: the development (main) branch and the Fixes 3.2 branch which includes additional fixes to the released 3.2.2 version. Developers, and those who like living on the bleeding edge and testing new features and fixes, will choose the development version; more normal users, who wish to use a stable branch with some additional fixes since the latest release version, will choose the Fixes branch. The instructions below cover both these branches.
399-
400-If it does not already exist, create a directory in which you'd like to keep the FPC source (eg `C:\Source`). Any normal user can do this. Now type the following command at a command prompt:
396+There are two current non-release branches of the Free Pascal Compiler: the development (main) branch and the Fixes 3.2 branch which includes additional fixes to the released 3.2.2 version. Developers, and those who like living on the bleeding edge and testing new features and fixes, will choose the development version; more normal users, who wish to use a stable branch with some additional fixes since the latest release version, will choose the Fixes branch. The instructions below cover both these branches.
401397
402-*For the Fixes branch of FPC 3.2*
398+If it does not already exist, create a directory in which you'd like to keep the FPC source (eg `C:\Source`). Any normal user can do this. Now type the following command at a command prompt:
403399
404-```dos
400+_For the Fixes branch of FPC 3.2_
401+```
405402C:\Source> git clone -b fixes_3_2 https://gitlab.com/freepascal.org/fpc/source.git fpc-fixes-3.2.0
406403```
407404
408-*For the Development (main) branch of FPC*
409-
410-```dos
405+_For the Development (main) branch of FPC_
406+```
411407C:\Source> git clone -b main https://gitlab.com/freepascal.org/fpc/source.git fpc-main
412408```
413409
414-Hint: To update your local copy of the repository with subsequent changes, you need only do:
415-
416-*For the Fixes branch of FPC 3.2*
410+Hint: To update your local copy of the repository with subsequent changes, you need only do:
417411
418-```dos
412+_For the Fixes branch of FPC 3.2_
413+```
419414C:\> cd C:\Source\fpc-fixes-3.2
420-C:\Source\fpc-fixes-3.2> git clean -f -d
421-C:\Source\fpc-fixes-3.2> git pull
415+ C:\Source\fpc-fixes-3.2> git clean -f -d
416+ C:\Source\fpc-fixes-3.2> git pull
422417```
423418
424-*For the Development (main) branch of FPC*
425-
426-```dos
419+_For the Development (main) branch of FPC_
420+```
427421C:\> cd C:\Source\fpc-main
428-C:\Source\fpc-trunk> git clean -f -d
429-C:\Source\fpc-trunk> git pull
422+ C:\Source\fpc-trunk> git clean -f -d
423+ C:\Source\fpc-trunk> git pull
430424```
431425
432426#### Obtaining a bootstrap compiler
433427
434-To obtain a bootstrap Free Pascal Compiler, download the distribution package [fpc-3.2.2.i386-win32.exe](https://www.freepascal.org/down/i386/win32.html) and run it - it is a self-extracting installer, so just follow the instructions to install it. The installer should set the PATH environment variable as appropriate.
428+To obtain a bootstrap Free Pascal Compiler, download the distribution package [fpc-3.2.2.i386-win32.exe](<https://www.freepascal.org/down/i386/win32.html>) and run it - it is a self-extracting installer, so just follow the instructions to install it. The installer should set the PATH environment variable as appropriate.
435429
436-Then restart windows.
430+Then restart windows.
437431
438432#### Compiling the FPC source
439433
440434**Before you start**
441435
442-- The installation PREFIX in the instructions that follow is totally dependent on the directory in which you installed FPC. The Windows FPC installer uses a default location of `C:\FPC` and the FPC 3.2.2 release files are placed in `C:\FPC\3.2.2`. Since versions change relatively frequently, it is recommended that you just select and maintain a single PREFIX default location without any regard to FPC version numbers. A reasonable PREFIX to adopt is the one used by the Windows FPC installer (`C:\FPC`) but you must also make sure that the `C:\FPC\bin\i386-win32\` directory is added to your path environment variable.
436+ * The installation PREFIX in the instructions that follow is totally dependent on the directory in which you installed FPC. The Windows FPC installer uses a default location of `C:\FPC` and the FPC 3.2.2 release files are placed in `C:\FPC\3.2.2`. Since versions change relatively frequently, it is recommended that you just select and maintain a single PREFIX default location without any regard to FPC version numbers. A reasonable PREFIX to adopt is the one used by the Windows FPC installer (`C:\FPC`) but you must also make sure that the `C:\FPC\bin\i386-win32\` directory is added to your path environment variable.
443437
444-- Check that the `make.exe` which is found first in your path environment variable is the GNU one included with your bootstrap FPC compiler. If you have a recent version of Delphi installed, watch out for its version of `make` being earlier in your path. It does not understand the FPC Makefile and you will receive many errors if you try to use it. You can check this by opening a command prompt and typing `make -v`. The result should be (or very similar):
438+ * Check that the `make.exe` which is found first in your path environment variable is the GNU one included with your bootstrap FPC compiler. If you have a recent version of Delphi installed, watch out for its version of `make` being earlier in your path. It does not understand the FPC Makefile and you will receive many errors if you try to use it. You can check this by opening a command prompt and typing `make -v`. The result should be (or very similar):
445439
446-```text
447- file:fpc_windows_make.png
448440```
449-
450-- If you need to change your path so that the correct `make.exe` is found, you can either do it temporarily or permanently.
451- - To change it temporarily (it is in effect only until you close the current command prompt) to find `make.exe` in `C:\FPC\3.2.2\bin\i386-win32`, at a command prompt type:
441+[![fpc windows make.png](/wiki-images/8/8a/fpc_windows_make.png)](</File:fpc_windows_make.png>)
442+```
452443
453-C:\Source\> set PATH=C:\FPC\3.2.2\bin\i386-win32;%PATH%
444+ * If you need to change your path so that the correct `make.exe` is found, you can either do it temporarily or permanently.
445+ * To change it temporarily (it is in effect only until you close the current command prompt) to find `make.exe` in `C:\FPC\3.2.2\bin\i386-win32`, at a command prompt type:
446+```
447+C:\Source> set PATH=C:\FPC\3.2.2\bin\i386-win32;%PATH%
448+```
454449
455-- - To change it permanently, open Control Panel \> System and choose "Advanced system settings" under "Related settings" towards the bottom of the page. Now choose "Environment Variables..." in the System Properties dialog. Here you will probably need to change the Path that appears under "System variables" so that `C:\FPC\3.2.2\bin\i386-win32` occurs first.
450+ * To change it permanently, open Control Panel > System and choose "Advanced system settings" under "Related settings" towards the bottom of the page. Now choose "Environment Variables..." in the System Properties dialog. Here you will probably need to change the Path that appears under "System variables" so that `C:\FPC\3.2.2\bin\i386-win32` occurs first.
456451
457452**Instructions**
458453
459-- At a command prompt, navigate to your local FPC source directory (eg `C:\Source\fpc-3.2.2`) by typing:
454+ * At a command prompt, navigate to your local FPC source directory (eg `C:\Source\fpc-3.2.2`) by typing:
460455
461-```dos
456+```
462457C:\> cd Source\fpc-3.2.2
463458```
464459
465-- Compile the FPC source with:
460+ * Compile the FPC source with:
466461
467-```dos
462+```
468463C:/Source/fpc-3.2.2> make distclean all
469464```
470465
471-- To overwrite an existing FPC installation in, for example, `C:\FPC`) type:
466+ * To overwrite an existing FPC installation in, for example, `C:\FPC`) type:
472467
473-```dos
468+```
474469C:/Source/fpc-3.2.2> make install PREFIX=C:\FPC
475470```
476471
477-- If you also need the cross-compiler to x86_64, type the following commands which will compile the cross-compiler and then install it:
472+ * If you also need the cross-compiler to x86_64, type the following commands which will compile the cross-compiler and then install it:
478473
479-```dos
474+```
480475C:/Source/fpc-3.2.2> make all OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=C:\FPC\3.2.2 PP=C:\FPC\3.2.2\bin\i386-win32\ppc386.exe DATA2INC=C:\FPC\3.2.2\bin\i386-win32\data2inc.exe
481-
482-C:/Source/fpc-3.2.2> make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=C:\FPC\3.2.2 PP=C:\FPC\3.2.2\bin\i386-win32\ppc386.exe DATA2INC=C:\FPC\3.2.2\bin\i386\win32\data2inc.exe
476+
477+ C:/Source/fpc-3.2.2> make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=C:\FPC\3.2.2 PP=C:\FPC\3.2.2\bin\i386-win32\ppc386.exe DATA2INC=C:\FPC\3.2.2\bin\i386\win32\data2inc.exe
483478```
484479
485-The cross-compiler to compile programs for Windows 64 bit may now be found here: `C:\FPC\3.2.2\bin\i386-win32\ppcrossx64`.
480+The cross-compiler to compile programs for Windows 64 bit may now be found here: `C:\FPC\3.2.2\bin\i386-win32\ppcrossx64`.
486481
487-Done!
482+Done!
488483
489484## macOS
490485
491-> **Warning:** If you are intending to also install Lazarus using the official macOS installation packages which install both FPC + Lazarus, please ignore these instructions and instead refer to [[Installing Lazarus on macOS]] to avoid having to resolve any resulting FPC conflicts.
486+[![Warning-icon.png](/wiki-images/b/b2/Warning-icon.png)](</File:Warning-icon.png>)
492487
488+**Warning:** If you are intending to also install Lazarus using the official macOS installation packages which install both FPC + Lazarus, please ignore these instructions and instead refer to [[Installing Lazarus on macOS]] to avoid having to resolve any resulting FPC conflicts.
489+
493490### Installing an FPC release from the official macOS packages
494491
495492#### Step 1: Download Xcode (optional)
496493
497-Xcode is a 12GB download which will take up 16GB of disk space. You **only** need to download and install the full Xcode development environment **if** you need:
498-
499-- the SDKs for **iOS**, **iPadOS**, watchOS and tvOS; or
500-- to validate and upload apps to the Mac App Store; or
501-- to [[Notarization for macOS 10.14.5+|notarise]] apps for distribution outside of the Mac App Store.
494+Xcode is a 12GB download which will take up 16GB of disk space. You **only** need to download and install the full Xcode development environment **if** you need:
502495
503-Xcode 11.3.1 for use on macOS 10.14 Mojave must now be installed by downloading it from [Apple Developer Connection](http://developer.apple.com/) (ADC), which requires free registration. Xcode 11.4.x for use on macOS 10.15 Catalina can be installed from the [Mac App store](https://apps.apple.com/us/genre/mac-developer-tools/id12002?mt=12). Note that you must first move any old Xcode versions from the Applications folder into the trash or rename the Xcode app (eg Xcode.app to Xcode_1014.app). You can select which version of Xcode to use with the command line utility `xcode-select`.
496+ * the SDKs for **iOS** , **iPadOS** , watchOS and tvOS; or
497+ * to validate and upload apps to the Mac App Store; or
498+ * to [[Notarization for macOS 10.14.5+|notarise]] apps for distribution outside of the Mac App Store.
504499
505-Older systems:
500+Xcode 11.3.1 for use on macOS 10.14 Mojave must now be installed by downloading it from [Apple Developer Connection](<http://developer.apple.com/>) (ADC), which requires free registration. Xcode 11.4.x for use on macOS 10.15 Catalina can be installed from the [Mac App store](<https://apps.apple.com/us/genre/mac-developer-tools/id12002?mt=12>). Note that you must first move any old Xcode versions from the Applications folder into the trash or rename the Xcode app (eg Xcode.app to Xcode_1014.app). You can select which version of Xcode to use with the command line utility `xcode-select`.
506501
507-The developer tools can be installed from the original macOS installation disks or a newer copy downloaded from the [Apple Developer Connection](http://developer.apple.com/) (ADC), which requires free registration. Download the Xcode file, it will end up in your Downloads directory as a zip file. Click it. It is unarchived into your Downloads directory. You may be happy with it there but maybe not. Other users will see the path to it but be unable to use it. And it is untidy there. So I moved mine and then told xcode-select where it was moved to (in a terminal) -
502+Older systems:
508503
509-``` bash
504+The developer tools can be installed from the original macOS installation disks or a newer copy downloaded from the [Apple Developer Connection](<http://developer.apple.com/>) (ADC), which requires free registration. Download the Xcode file, it will end up in your Downloads directory as a zip file. Click it. It is unarchived into your Downloads directory. You may be happy with it there but maybe not. Other users will see the path to it but be unable to use it. And it is untidy there. So I moved mine and then told xcode-select where it was moved to (in a terminal) -
505+```
510506mv Downloads/Xcode.app /Developer/.
511-sudo xcode-select -s /Developer/Xcode.app/Contents/Developer
507+ sudo xcode-select -s /Developer/Xcode.app/Contents/Developer
512508```
513509
514510#### Step 2: Xcode Command Line Tools
515511
516-This is shown here as a separate step because it really is a separate step in addition to Step 1. Don't confuse this with the internal Xcode command line tools that the Xcode GUI will tell you are already installed. FPC does not use those Xcode internal command line tools, so do the following (it is quick and easy)-
517-
518-``` bash
512+This is shown here as a separate step because it really is a separate step in addition to Step 1. Don't confuse this with the internal Xcode command line tools that the Xcode GUI will tell you are already installed. FPC does not use those Xcode internal command line tools, so do the following (it is quick and easy)-
513+```
519514sudo xcode-select --install
520-sudo xcodebuild -license accept
515+ sudo xcodebuild -license accept
521516```
522517
523-You only need to enter the first of the two commands above unless you have also installed the full Xcode package. If you have only installed the command line tools, you should omit entering the *xcodebuild* command.
518+You only need to enter the first of the two commands above unless you have also installed the full Xcode package. If you have only installed the command line tools, you should omit entering the _xcodebuild_ command.
524519
525520#### Step 3: Download FPC
526521
527-Download the Free Pascal Compiler (FPC) and FPC source from the [Free Pascal website](https://www.freepascal.org/download.html). When you arrive at the download page, select a mirror and then choose the correct version for your operating system.
522+Download the Free Pascal Compiler (FPC) and FPC source from the [Free Pascal website](<https://www.freepascal.org/download.html>). When you arrive at the download page, select a mirror and then choose the correct version for your operating system.
528523
529-These installation packages are built by the FPC developers and track formal releases. As these installation packages are not code signed nor notarized by Apple, you need to either control-click on the installation package and choose "Open" or right-click on the installation package and choose "Open" in the contextual menu and confirm you want to install from an Unknown Developer.
524+These installation packages are built by the FPC developers and track formal releases. As these installation packages are not code signed nor notarized by Apple, you need to either control-click on the installation package and choose "Open" or right-click on the installation package and choose "Open" in the contextual menu and confirm you want to install from an Unknown Developer.
530525
526+### Installing from source
527+
528+There are two current non-release branches of the Free Pascal Compiler: the development (trunk) branch and the Fixes 3.2 branch which includes additional fixes to the released 3.2.2 version. Developers, and those who like living on the bleeding edge and testing new features and fixes, will choose the development version; more normal users, who wish to use a stable branch with some additional fixes since the latest release version, will choose the Fixes branch. The instructions below cover both these branches.
529+
530+The source code is kept in a version control system called _git_ :
531+
532+ * macOS 10.5 and higher already contain a command line git client if you have installed the Xcode command line utilities.
533+
534+ * You also need the latest released Free Pascal Compiler version (3.2.2 as of March 2022) installed in order to be able to successfully compile the development (trunk) version.
535+
536+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Note:** **When building a native aarch64 Free Pascal Compiler (ppca64) for an Apple Silicon M1 processor Mac, change the CPU_TARGET in the instructions below from x86_64 (Intel 64 bit) to aarch64 (ARM 64 bit - Apple Silicon M1) and change any reference to ppcx64 to ppca64**
537+
538+#### FPC development version
539+
540+ * [[FPC New Features Trunk|FPC New Features in development]]
541+ * [[User Changes Trunk|FPC User Changes in development]] \- may break existing code.
542+
543+Note that since the development version of FPC (was known as "trunk" in SVN; now known as "main" in GIT) is by definition still under development, some of the features may still change before they end up in a release version.
544+
545+Create a directory where you would like to put the source (eg fpc_main in your home directory). You don't need to be root to do this. Any normal user can do this. Open an Applications > Utilities > Terminal and do the following:
546+```
547+[]$ git clone -b main https://gitlab.com/freepascal.org/fpc/source.git fpc_main
548+```
549+
550+This will create a directory called `fpc_main` and download the FPC main source to it.
551+
552+To subsequently update your local source repository with the latest source changes you can simply do:
553+```
554+[]$ cd
555+ []$ cd fpc_main
556+ []$ git clean -f -d
557+ []$ git pull
558+```
559+
560+To build and install FPC (the highlighted text should be all on one line):
561+```
562+[]$ cd
563+ []$ cd fpc_main
564+ []$ make distclean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
565+ []$ sudo make install FPC=$PWD/compiler/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64
566+```
567+
568+You will also need to update the links for the compiler in `/usr/local/bin` which will be pointing to the previous FPC version. For example:
569+```
570+[]$ cd /usr/local/bin
571+ []$ sudo rm ppc386
572+ []$ sudo rm ppcx64
573+ []$ sudo ln -s /usr/local/lib/fpc/3.3.1/ppc386
574+ []$ sudo ln -s /usr/local/lib/fpc/3.3.1/ppcx64
575+```
576+
577+Note that you will need to build a new `ppc386` compiler if you want to continue to compile 32 bit applications by replacing these lines (this is not be possible after Xcode 11.3.1 and macOS 10.14.6 Mojave because of Apple's removal of the 32 bit frameworks):
578+```
579+[]$ make clean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
580+ []$ sudo make install FPC=$PWD/compiler/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64
581+```
582+
583+with these two lines:
584+```
585+[]$ make clean all FPC=/usr/local/lib/fpc/3.2.2/ppc386 OS_TARGET=darwin CPU_TARGET=i386 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
586+ []$ sudo make install FPC=$PWD/compiler/ppc386 OS_TARGET=darwin CPU_TARGET=i386
587+```
588+
589+#### FPC Fixes 3.2
590+
591+Create a directory where you would like to put the source (eg `fpc_fixes32` in your home directory). You don't need to be root to do this. Any normal user can do this. Open an Applications > Utilities > Terminal and do the following:
592+```
593+[]$ git clone -b fixes_3_2 https://gitlab.com/freepascal.org/fpc/source.git fpc_fixes32
594+```
595+
596+This will create a directory called `fpc_fixes32` and download the FPC source to it.
597+
598+To subsequently update your local copy of the repository source with the latest source changes you can simply do:
599+```
600+[]$ cd fpc_fixes32
601+ []$ git clean -f -d
602+ []$ git pull
603+```
604+
605+To build and install FPC (the highlighted text should be all on one line):
606+```
607+[]$ cd
608+ []$ cd fpc_fixes32
609+ []$ make distclean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
610+ []$ sudo make install FPC=$PWD/compiler/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64
611+```
612+
613+You will also need to update the links for the compiler in `/usr/local/bin` which will be pointing to the previous FPC version. For example:
614+```
615+[]$ cd /usr/local/bin
616+ []$ sudo rm ppc386
617+ []$ sudo rm ppcx64
618+ []$ sudo ln -s /usr/local/lib/fpc/fixes-3.2/ppc386
619+ []$ sudo ln -s /usr/local/lib/fpc/fixes-3.2/ppcx64
620+```
621+
622+Note that you will need to build a new `ppc386` compiler if you want to continue to compile 32 bit applications by replacing these lines (this may not be possible after Xcode 11.3.1 and macOS 10.14.6 Mojave because of Apple's removal of the 32 bit frameworks):
623+```
624+[]$ make clean all FPC=/usr/local/lib/fpc/3.2.2/ppc386 OS_TARGET=darwin CPU_TARGET=i386 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
625+ []$ sudo make install FPC=$PWD/compiler/ppc386 OS_TARGET=darwin CPU_TARGET=i386
626+```
627+
531628### Other installation options
532629
533-See [[Other macOS installation options|Other FPC Installation Options]].
630+See [[Other macOS installation options|Other FPC Installation Options]].
534631
535632## Testing the FPC Install
536633
537-You might like to try a simple and quick test of FPC at this stage. From the command line (Mac - Open an Application \> Utilities \> Terminal) start an editor (e.g. pico or nano), paste this very short program and save it as the file `helloworld.pas` (using the WriteOut command in GNU nano):
538-
539-``` pascal
634+You might like to try a simple and quick test of FPC at this stage. From the command line (Mac - Open an Application > Utilities > Terminal) start an editor (e.g. pico or nano), paste this very short program and save it as the file `helloworld.pas` (using the WriteOut command in GNU nano):
635+```
540636program helloworld;
541-begin
542- writeln('hello world !');
543-end.
637+ begin
638+ writeln('hello world !');
639+ end.
544640```
545641
546-Now exit the editor and compile this simple code by typing this command, before pressing `Enter`:
547-
548-``` bash
642+Now exit the editor and compile this simple code by typing this command, before pressing `↵ Enter`:
643+```
549644fpc helloworld.pas
550645```
551646
552-It should very quickly make an executable called, you guessed it, "helloworld". Run this executable by typing this command and then pressing `Enter`:
553-
554-``` bash
647+It should very quickly make an executable called, you guessed it, "helloworld". Run this executable by typing this command and then pressing `↵ Enter`:
648+```
555649./helloworld
556650```
557651
558-If that worked, well done!
652+If that worked, well done!
559653
560654## Useful command-line switches for compiling from source
561655
562-- Significantly speed up the FPC source tree compilation
563- - `FPMAKEOPT="-T x"` (x = the number of CPU cores you have)
656+ * Significantly speed up the FPC source tree compilation
657+ * `FPMAKEOPT="-T x"` (x = the number of CPU cores you have)
564658
565-- Reduce the number of times the compiler itself gets recompiled
566- - `NOWPOCYCLE=1`
659+ * Reduce the number of times the compiler itself gets recompiled
660+ * `NOWPOCYCLE=1`
567661
568-- Add debug information and disable optimizations during compilation of the compiler/RTL
569- - `OPT="-gl -O-"`
662+ * Add debug information and disable optimizations during compilation of the compiler/RTL
663+ * `OPT="-gl -O-"`
570664
571665## Installing cross compilers
572666
573-A cross compiler allows you to create binaries (executables) for a platform different from the platform being used for compilation. For example, working under macOS and creating executables for Win64 or Win32 (only up to and including macOS 10.14.6 due to Apple's removal of 32 bit frameworks). For details on how to do this, see [[Cross compiling|Cross Compiling]].
667+A cross compiler allows you to create binaries (executables) for a platform different from the platform being used for compilation. For example, working under macOS and creating executables for Win64 or Win32 (only up to and including macOS 10.14.6 due to Apple's removal of 32 bit frameworks). For details on how to do this, see [[Cross compiling|Cross Compiling]].
574668
575669## See also
576670
577-- [[FPC|FPC Wiki Documentation]].
578-- [FPC Official Documentation](https://www.freepascal.org/docs.html).
579-- [[FPC New Features 3.2.2|FPC 3.2.2 New Features]].
580-- [[User Changes 3.2.2|FPC 3.2.2 User Changes]] - may break existing code.
581-- [[FPC New Features Trunk|FPC New Features in development version]].
582-- [[User Changes Trunk|FPC User Changes in development version]] - may break existing code.
671+ * [[FPC|FPC Wiki Documentation]].
672+ * [FPC Official Documentation](<https://www.freepascal.org/docs.html>).
673+ * [[FPC New Features 3.2.2|FPC 3.2.2 New Features]].
674+ * [[User Changes 3.2.2|FPC 3.2.2 User Changes]] \- may break existing code.
675+ * [[FPC New Features Trunk|FPC New Features in development version]].
676+ * [[User Changes Trunk|FPC User Changes in development version]] \- may break existing code.
583677
584678---
585-*From the Free Pascal wiki, page "Installing the Free Pascal Compiler", as it stood on 2024-03-04 after a change by Dbannon, 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).*
586-Category: FPC
587-Category: Install
679+*From the Free Pascal wiki, page "Installing the Free Pascal Compiler", as the Internet Archive kept it on 2025-06-18, last changed on 2024-08-23. 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).*

Back to history