[Lazarus] Proposal for changing fpc version on the fly in the IDE

patspiper patspiper at gmail.com
Thu Aug 22 14:39:47 CEST 2013


The following applies at least to Linux, and should probably apply as 
well to other OSes.

When multiple FPC versions are used, the fpc binary and related 
utilities are usually located in <fpc folder>/<fpc version>/bin, and the 
compiler itself (ppcxxx) in <fpc folder>/<fpc version>/lib/fpc/<fpc 
version>. The folders could be different than these, but the point to 
note is that there are 2 folders that rely on the fpc version.

Furthermore, it is not good practice to specify the ppcxxx compiler in 
the compiler path in the IDE options, especially when cross-compiling. 
The fpc binary must be specified instead, and that binary must be able 
to locate the ppcxxx folder.

I define the compiler path in the IDE options as 'fpc' only, and ensure 
that both paths above (with the required fpc version to use) are 
exported in a shell before launching the IDE from that shell (actually I 
use a script with a menu to select the version). This setup runs 
smoothly even for cross-compiling.

However to switch from one fpc version to another, one must quit the IDE 
and the shell, and repeat the process above with the new paths.

In order to avoid quitting the IDE, I suggest the following:

- If the compiler path in the IDE options is set as a relative path to 
the fpc binary, or more specifically 'fpc' only, then one would assume 
that the required paths have been exported, and nothing more needs to be 

- If on the other hand the compiler path in the IDE options is set as an 
absolute path to the fpc binary (indicating that no paths have been 
exported), then an additional edit box can be used where one specifies 
the relative path of the ppcxxx compiler (relative to the fpc binary 
folder), and thus the IDE can feed that path to the fpc binary using 
'<absolute path to the fpc binary>/fpc -Xp<relative path of ppc 
compiler>' when launching the fpc binary. Here two sub cases arise:

   * If the FPCVER macro does not appear in any of the 2 paths 
(<absolute path to the fpc binary> and <relative path of ppc compiler>) 
then the fpc binary can be queried to set the FPCVER macro.

   * If any of the 2 paths depend on the FPCVER macro, then another edit 
box (with dropdown history) is used to force the FPCVER macro to the 
required value instead of querying the fpc binary. In that case, 
changing the FPCVER macro will ensure the use of the right FPC version. 
As a sanity check, the fpc binary can be queried for the fpc version 
which is compared to the user specified FPCVER macro.



More information about the Lazarus mailing list