Difference between revisions of "FPC Version Switcher"

From Free Pascal wiki
Jump to navigationJump to search
m
m
Line 2: Line 2:
  
 
[[Image:fpcversion.jpg]]
 
[[Image:fpcversion.jpg]]
 +
 
Pre-requisites:
 
Pre-requisites:
 
- Specify "fpc" as compiler executable in the IDE's Tools/Options/Files  
 
- Specify "fpc" as compiler executable in the IDE's Tools/Options/Files  
Line 72: Line 73:
 
THe FPC version switcher package allows one to set the above described options. It goes even further by providing a dropdown list in the IDE Tools/Options/Compiler Version in order to select the required fpc version, and setting the UseFPCVersion macro accordingly.
 
THe FPC version switcher package allows one to set the above described options. It goes even further by providing a dropdown list in the IDE Tools/Options/Compiler Version in order to select the required fpc version, and setting the UseFPCVersion macro accordingly.
  
Now, if our 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 the path based on that macro (eg /usr/lib/fpc/$(UseFPCVersion)). Moreover, any IDE macro other than $(FPCVersion) and that doesn't depend on it can be used (eg $Env(HOME)/fpc/lib/$(UseFPCVersion)).
+
Now, if our 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 the path 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 (eg $Env(HOME)/fpc/lib/$(UseFPCVersion)).

Revision as of 00:34, 25 February 2015

THe FPC version switcher package integrates with the Lazarus IDE in order to allow easy switching of fpc versions.

fpcversion.jpg

Pre-requisites: - Specify "fpc" as compiler executable in the IDE's Tools/Options/Files - A homogeneous directory structure (path for different fpc versions should differ only by version number)

Background: The actual FPC compiler / cross-compiler is usually ppcxxx or ppcrossxxx.

For an i386 (32 bit) system: - ppc386 is the actual compiler - ppcrossx64 is the x86_64 cross compiler (produces 64 bit binaries) - ppcrossarm is the arm cross compiler (produces arm binaries) etc...

For an x86_64 (64 bit) system: - ppcx64 is the actual compiler - ppcross386 is the i386 cross compiler (produces 32 bit binaries) - ppcrossarm is the arm cross compiler (produces arm binaries) etc...

Rather 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:

- The OS should be able to locate the fpc executable by either:

  * adding the fpc executable path to the environment PATH variable (eg export PATH=/usr/bin;$PATH) and just calling "fpc".
  * providing a fully qualified path (eg /usr/bin/fpc).

- The fpc executable should be told what the target cpu by using the -P<target_cpu> switch so that it can deduce the actual compiler name.

- The fpc executable should be able to locate the actual compiler by either:

  * adding the actual compiler (ppcxxx) path to the environment PATH variable (eg export PATH=/usr/lib/fpc;$PATH)
  * calling fpc with the -Xp<ppcxxx_path> switch to inform it about the location of the actual compiler (eg: fpc -Xp/usr/lib/fpc)

Furthermore, the -PB switch will just output the actual compiler name for a target cpu. On an i386 system (32 bit): fpc -PB will output ppc386 (default cpu target) fpc -Pi386 -PB will output ppc386 fpc -Px86_64 -PB will output ppcrossx64 fpc -Parm -PB will output ppcrossarm etc...

On an x86_64 system (64 bit): fpc -PB will output ppcx64 (default cpu target) fpc -Px86_64 -PB will output ppcx64 fpc -Pi386 -PB will output ppcross386 fpc -Parm -PB will output ppcrossarm etc...

The -PP switch just outputs the processor name On an i386 system (32 bit), the output is i386 On an x86_64 system (64 bit), the output is x86_64

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). Some users put symlinks pointing to the actual compilers and that include the version in one folder, and the -V switch is convenient in this case.

To sum up, calling fpc can have different forms: fpc -P<cpu_target> /usr/bin/fpc -Xp/usr/lib/fpc -P<cpu_target> /usr/bin/fpc -Xp/usr/lib/fpc -V3.1.1 -P<cpu_target> etc...

One can find out the actual compiler name for any form by using the -PB switch: /usr/bin/fpc -Xp/usr/lib/fpc -V3.1.1 -P<cpu_target> -PB

The actual compiler, once called, needs to locate some fpc utilities or tool by either:

  * adding the fpc tools path to the environment PATH variable (eg export PATH=/usr/bin;$PATH)
  * Adding -FD<fpc_tools_path> switch to fpc.cfg to specify the location of the fpc tools (eg: -FD/usr/bin)
  * calling fpc with the -FD<fpc_tools_path> switch to inform it about the location of the fpc tools (eg: fpc -FD/usr/bin)

Finally, for cross compiling, the cross binutils folder should be in the environment PATH variable.

THe FPC version switcher package allows one to set the above described options. It goes even further by providing a dropdown list in the IDE Tools/Options/Compiler Version in order to select the required fpc version, and setting the UseFPCVersion macro accordingly.

Now, if our 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 the path 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 (eg $Env(HOME)/fpc/lib/$(UseFPCVersion)).