Sign in Join
Wiki copytemporary

FPC Version Switcher: what changed

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

OldNewLine
11## About
22
33The FPC version switcher package integrates with the Lazarus IDE in order to allow easy switching of fpc versions.
44
5-<figure>
6-<img src="fpcversion.jpg" title="fpcversion.jpg" />
7-<figcaption>fpcversion.jpg</figcaption>
8-</figure>
5+![](/wiki-images/0/05/Fpcversion.jpg)
96
107## Background
118
129### Actual compiler naming convention
1310
1411The actual FPC compiler / cross-compiler is usually ppcxxx or ppcrossxxx where xxx denotes the cpu target.
1512
1613For an i386 (32 bit) system:
1714
1815- ppc386 is the actual compiler
1916- ppcrossx64 is the actual x86_64 cross compiler (produces 64 bit binaries)
2017- ppcrossarm is the actual arm cross compiler (produces arm binaries)
2118
2219etc...
2320
2421For an x86_64 (64 bit) system:
2522
2623- ppcx64 is the actual compiler
2724- ppcross386 is the actual i386 cross compiler (produces 32 bit binaries)
2825- ppcrossarm is the actual arm cross compiler (produces arm binaries)
2926
3027etc...
3128
3229### The fpc frontend executable
3330
3431Rather than letting one guess the actual compiler name for a certain target cpu and call it directly, FPC provides the fpc front end executable, which takes care of calling the right actual compiler for the required target cpu. To do that, 3 things are needed:
3532
3633- The OS should be able to locate the fpc executable by either:
3734 - adding the fpc executable path to the environment PATH variable (eg export PATH=/usr/bin;\$PATH) and just calling "fpc".
3835 - providing a fully qualified path (eg /usr/bin/fpc).
3936
4037- The fpc executable should be told what the target cpu is by using the -P\<target_cpu\> switch so that it can deduce by itself the actual compiler name.
4138
4239- The fpc executable should be able to locate the actual compiler by either:
4340 - adding the actual compiler (ppcxxx) path to the environment PATH variable (eg export PATH=/usr/lib/fpc;\$PATH)
4441 - calling fpc with the -Xp\<ppcxxx_path\> switch to inform it about the location of the actual compiler (eg: fpc -Xp/usr/lib/fpc)
4542
4643Some users opt to create in one folder symlinks with the fpc version suffixed (eg ppc386-3.1.1), and pointing to the actual compilers. The -V\<version\> switch lets the fpc executable append \<version\> to the actual compiler name (eg fpc -V3.1.1 on a 386 system will look for ppc386-3.1.1).
4744
4845To sum up, calling fpc can take different forms:
4946
5047- fpc -P\<cpu_target\>
5148- /usr/bin/fpc -Xp/usr/lib/fpc -P\<cpu_target\>
5249- /usr/bin/fpc -Xp/usr/lib/fpc -V3.1.1 -P\<cpu_target\>
5350
5451etc...
5552
5653### Checking fpc's mechanism
5754
5855#### Processor name
5956
6057The -PP switch just displays the processor name.
6158
6259- On an i386 system (32 bit), the output of fpc -PP is i386
6360- On an x86_64 system (64 bit), the output of fpc -PP is x86_64
6461
6562#### Actual compiler name name
6663
6764The -PB switch will make fpc just display the actual compiler name for a target cpu.
6865
6966On an i386 system (32 bit):
7067
7168- fpc -PB will output ppc386 (default cpu target)
7269- fpc -Pi386 -PB will output ppc386
7370- fpc -Px86_64 -PB will output ppcrossx64
7471- fpc -Parm -PB will output ppcrossarm
7572
7673etc...
7774
7875On an x86_64 system (64 bit):
7976
8077- fpc -PB will output ppcx64 (default cpu target)
8178- fpc -Px86_64 -PB will output ppcx64
8279- fpc -Pi386 -PB will output ppcross386
8380- fpc -Parm -PB will output ppcrossarm
8481
8582etc...
8683
8784One can even use it as follows:
8885
8986\<path_to_fpc_bin\>/fpc -Xp\<\<path_to_fpc_lib\> -V\<fpc_version\> -P\<cpu_target\> -PB
9087
9188### Compiler utilities
9289
9390The actual compiler, once called, may need to locate some utilities. The path can be specified by either:
9491
9592- Adding the compiler utilities path to the environment PATH variable (eg export PATH=/usr/local/bin/compiler_utilities;\$PATH)
9693- Adding the -FD\<compiler_utilities_path\> switch to fpc.cfg (eg: -FD/usr/local/bin/compiler_utilities)
9794- Calling fpc with the -FD\<compiler_utilities_path\> switch (eg: fpc -FD/usr/local/bin/compiler_utilities)
9895
9996### Cross binutils
10097
10198For cross compiling, the cross binutils (cross assembler, cross linker, ...) folder should be in the environment PATH variable.
10299
103100## FPC Version Switcher
104101
105102The FPC version switcher package allows tweaking all the above options and even providing a dropdown list in the IDE Tools/Options/Compiler Version in order to select the required fpc version, and set the \$(UseFPCVersion) macro accordingly.
106103
107104Now, if the installations of the different fpc versions differ only by the version number (eg /usr/lib/fpc/2.6.4 and /usr/lib/fpc/3.1.1), then one can specify paths based on that macro (eg /usr/lib/fpc/\$(UseFPCVersion)). Moreover, any IDE macro other than \$(FPCVER) and that doesn't depend on it can be used in the paths (eg \$Env(HOME)/fpc/lib/\$(UseFPCVersion)).
108105
109106### Pre-requisites
110107
1111081. Having multiple fpc versions installed
1121092. Having a homogeneous directory structure (paths for different fpc versions should differ only by version number)
1131103. Modifying all paths in fpc.cfg to depend on FPC's \$FPCVERSION macro (where applicable)
1141114. Not having fpc related paths in the environment PATH variable (except as outlined in #Setting the fpc frontend executable path)
1151125. Having "fpc" as compiler executable in the IDE's Tools/Options/Files
116113
117114### Installation
118115
119116Open fpcversionswitcher.lpk in the lazarus/components/fpcversionswitcher folder, compile and install it and restart the IDE. A new frame will be available in Tools/Options/Compiler Version.
120117
121118### FPC version selection
122119
123120Enter or select the required FPC version using the dropdown list. This will set the \$(UseFPCVersion) macro accordingly. Note that this macro is different from the IDE's \$(FPCVER) macro.
124121
125122### Setting the fpc frontend executable path
126123
127124Enter or locate the absolute path of the fpc frontend executable. You can use \$(UseFPCVersion) and/or any IDE macro other than and doesn't depend on \$(FPCVER).
128125
129126Select how the IDE should locate the fpc frontend:
130127
131128- By adding the path to the environment PATH variable
132129- By calling the fpc executable with a fully qualified path
133130- By doing nothing and assuming that the path has been predefined in the environment PATH variable
134131
135132### Setting the actual compiler executable path
136133
137134Enter or locate the absolute path of the actual compiler executable. You can use \$(UseFPCVersion) and/or any IDE macro other than and doesn't depend on \$(FPCVER).
138135
139136Select how the IDE should locate the actual compiler:
140137
141138- By adding the path to the environment PATH variable
142139- By calling the fpc executable with the Xp switch and a fully qualified path
143140
144141### Setting the compiler utilities path
145142
146143Enter or locate the absolute path of the compiler utilities. You can use \$(UseFPCVersion) and any IDE macro other than and/or doesn't depend on \$(FPCVER).
147144
148145Select how the IDE should locate the actual compiler:
149146
150147- By adding the path to the environment PATH variable
151148- By calling the fpc executable with the FD switch and a fully qualified path
152149- By doing nothing and assuming that the FD switch is used in fpc.cfg
153150
154151### Enabling the version suffix for the actual compiler
155152
156153Check "ppc executable has suffix" if the actual compilers or symlinks pointing to them have the fpc version suffixed (eg ppc386-3.1.1)
157154
158155### Mechanism
159156
160157- FPC Version Switcher modifies the environment PATH variable for settings that require it to do so
161158- FPC Version Switcher passes to the IDE a prefix (the fpc frontend path or empty) which the IDE should prepend to "fpc"
162159- FPC Version Switcher passes to the IDE a suffix (the -Xp, -FD, and -V switches if any) which the IDE should append to "fpc"
163160
164161### Verifying the settings
165162
166163The check button will display:
167164
168165- If the fpc frontend path should exist in the environment PATH variable before launching the IDE
169166- Which paths will be added to the environment PATH variable
170167- How the IDE should call the fpc frontend
171168
172169### Usage
173170
174171To change the fpc version, it is enough to go to Tools/Options/Compiler version and select the required FPC version. You can then compile your projects or the IDE with that version.
175172
176173### Use cases with different fpc and ppc folders setups
177174
178175For the sake of brevity, the fpc frontend executable folder and the actual compiler folder will be denoted as the bin and lib folders respectively,
179176
180177#### Common bin folder and separate lib folders
181178
182179- fpc executable path: /usr/local/bin
183180- ppcxxx executable path: /usr/local/lib/fpc/\$(UseFPCVersion)
184181
185182#### Separate bin folders and separate lib folders
186183
187184- fpc executable path: \$Env(HOME)/fpc/\$(UseFPCVersion)/bin
188185- ppcxxx executable path: \$Env(HOME)/fpc/\$(UseFPCVersion)/lib/fpc/\$(UseFPCVersion)
189186
190187#### Common bin folder (fpc executable + ppcxxx-XYZ symlinks) and separate lib folders using symlinks /usr/local/bin/ppcxxx-\$(UseFPCVersion) -\> /usr/local/lib/fpc/\$(UseFPCVersion)/ppcxxx
191188
192189- fpc executable path: /usr/local/bin
193190- ppcxxx executable path: /usr/local/bin
194191- ppc executable has suffix: Yes
195192
196193### Known issues
197194
198195This is a work in progress and therefore not all options are functional. What needs to be completed is the prefix/suffix link between FPC Version Switcher and the IDE. Therefore options that pass paths or switches to the IDE should not be used for now.
199196
200197### Wishlist
201198
202199- To have a dropdown button next to the Run button so that switching FPC versions is done without even going into Tools/Options
203200- To have separate FPC versions for projects and the IDE
204201
205202---
206203*From the Free Pascal wiki, page "FPC Version Switcher", as it stood on 2015-02-27 after a change by Stephano, 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).*
207204Category: FPC
208205Category: IDE
209206Category: Lazarus
210207Category: Packages

Back to history