Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2020-06

Switching Lazarus between fpc 3.2.0 and 3.0.4 - how to?

17 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

Is it possible to switch Lazarus between using fpc 3.0.4 and 3.2.0 so as to compare the two easily?
If possible, how?
Or do I need a complete installation Lazarus/Fpc for the two fpc versions?

Bo Berglund Developer in Sweden

Reply by email

Michael Van Canneyt
to Bo Berglund: Is it possible to switch Lazarus between using fpc 3.0.4 and 3.2.0 so as to compare the…
Bo Berglund wrote
Is it possible to switch Lazarus between using fpc 3.0.4 and 3.2.0 so as to compare the two easily?

Yes.

Just install the new FPC alongside the old one.

The simplest is then to copy the lazarus settings directory, and create a shortcut where you start lazarus with --pcp=/path/to/copy

In this, under Tools-Options dialog, page Environment-Files set
- the correct compiler binary in 'Compiler Executable',
- and the correct path to the 3.2.0 sources in 'FPC Source directory'

That's it.

Now you can start 2 instances of lazarus, with a different setting for the compiler version.

I have 4 or 5 such versions.

Michael.

Reply by email

Bo Berglund
to Michael Van Canneyt
Michael Van Canneyt wrote 24 lines
On Sun, 21 Jun 2020, Bo Berglund via lazarus wrote: > Is it possible to switch Lazarus between using fpc 3.0.4 and 3.2.0 so > as to compare the two easily? Yes. Just install the new FPC alongside the old one. The simplest is then to copy the lazarus settings directory, and create a shortcut where you start lazarus with --pcp=/path/to/copy In this, under Tools-Options dialog, page Environment-Files set - the correct compiler binary in 'Compiler Executable', - and the correct path to the 3.2.0 sources in 'FPC Source directory' That's it. Now you can start 2 instances of lazarus, with a different setting for the compiler version. I have 4 or 5 such versions.

Thanks, that seems simple enough. :)

Just a follow-up:
After downloading the 3.2.0 sources via svn I went into the new 3.2.0 dir and did (I am using an RPi4 computer with 4GB RAM):

$ time make all FPC=/home/pi/bin/ppcarm OPT=-dFPC_ARMHF

So I did not do a "make install"...

I also did:
$ cp .lazarus_2.0.8 ./.lazarus_2.0.8_3.2

Is the above OK for using the compiler as outlined above pointing the shortcut to to the new dir as you outlined?

Beware though!!!!
-----------------
I have fallen into the trap of copying the pcp dir when installing a new version of Lazarus before. Then unbeknown to me Lazarua used installed components where the paths pointed to the *previous* version.
That resulted in both Lazarus versions sharing the exact same files including generated binaries....

So I had to scan the files in the pcp dir for the old pcp dir path and change it to the new path!
It turned out to be a bunch of xml and cfg files, in my case 13 cases:

codetoolsoptions.xml
environmentoptions.xml
includelinks.xml
inputhistory.xml
packagefiles.xml
idemake.cfg

Bo Berglund Developer in Sweden

Reply by email

Michael Van Canneyt
to Bo Berglund
Show quoted text 6 lines
> Now you can start 2 instances of lazarus, with a different setting for the > compiler version. > > I have 4 or 5 such versions. Thanks, that seems simple enough. :)

It is.

Show quoted text 14 lines
Just a follow-up: After downloading the 3.2.0 sources via svn I went into the new 3.2.0 dir and did (I am using an RPi4 computer with 4GB RAM): $ time make all FPC=/home/pi/bin/ppcarm OPT=-dFPC_ARMHF So I did not do a "make install"... I also did: $ cp .lazarus_2.0.8 ./.lazarus_2.0.8_3.2 Is the above OK for using the compiler as outlined above pointing the shortcut to to the new dir as you outlined?

You need to do the "make install".
How else will the compiler find the units when compiling ?

Show quoted text 9 lines
Beware though!!!! ----------------- I have fallen into the trap of copying the pcp dir when installing a new version of Lazarus before. Then unbeknown to me Lazarua used installed components where the paths pointed to the *previous* version. That resulted in both Lazarus versions sharing the exact same files including generated binaries....

This is so, but it does not have to be a problem: you must not recompile lazarus itself using such a secondary copy.

I only recompile lazarus using the configuration with the official released FPC.

Michael.

Reply by email

Bo Berglund
to Michael Van Canneyt
Michael Van Canneyt wrote
This is so, but it does not have to be a problem: you must not recompile lazarus itself using such a secondary copy.

Since Lazarus recompiles itself when one installs a new package, how can I deal with that?

The compiler executable was set in Lazarus to "fpc" i.e. no path at all.
I changed it to /home/pi/dev/fpc/3.2.0/compiler/ppcarm Is this the correct way to do it?

Lazarus help/about still says FPC is version 3.0.4 (I guess it knows which version compiled it)..

Is there a way I can verify if the settings are modified correctly and the new fpc is in use for this Lazarus invocation?

Bo Berglund Developer in Sweden

Reply by email

Michael Van Canneyt
to Bo Berglund
Bo Berglund wrote 8 lines
On Sun, 21 Jun 2020 11:12:17 +0200 (CEST), Michael Van Canneyt via lazarus wrote: > This is so, but it does not have to be a problem: you must not recompile > lazarus itself using such a secondary copy. Since Lazarus recompiles itself when one installs a new package, how can I deal with that?

Always make sure you do this with the default.

Show quoted text 5 lines
The compiler executable was set in Lazarus to "fpc" i.e. no path at all. I changed it to /home/pi/dev/fpc/3.2.0/compiler/ppcarm Is this the correct way to do it?

Yes.

Lazarus help/about still says FPC is version 3.0.4 (I guess it knows which version compiled it)..

Yes.

Is there a way I can verify if the settings are modified correctly and the new fpc is in use for this Lazarus invocation?

Compile a program

begin
writeln({$I %FPCVERSION});
end.

and check the output.

Michael.

Reply by email

Mattias Gaertner
to Bo Berglund: On Sun, 21 Jun 2020 11:12:17 +0200 (CEST), Michael Van Canneyt via Since Lazarus…
[...] Since Lazarus recompiles itself when one installs a new package, how can I deal with that?

The IDE uses the default fpc, set in Tools / Options / Environment / Files.
Every project can use its own compiler.
When you install a package, the default compiler is used.

The compiler executable was set in Lazarus to "fpc" i.e. no path at all.

Then it is searched via PATH.

I changed it to /home/pi/dev/fpc/3.2.0/compiler/ppcarm

The 'compiler' folder looks like the FPC source directory.

When you install fpc, the path should be something like /installbasedir/lib/fpc/3.2.0/ppcarm

Is this the correct way to do it? Lazarus help/about still says FPC is version 3.0.4 (I guess it knows which version compiled it)..

Yes.

Is there a way I can verify if the settings are modified correctly and the new fpc is in use for this Lazarus invocation?

View / IDE Internals / About FPC

Mattias

Reply by email

Bo Berglund
to Mattias Gaertner
Mattias Gaertner wrote 7 lines
> I changed it to /home/pi/dev/fpc/3.2.0/compiler/ppcarm The 'compiler' folder looks like the FPC source directory. When you install fpc, the path should be something like /installbasedir/lib/fpc/3.2.0/ppcarm

Thanks for the pointer!

Yes this is the source dir.
I now changed it to:
/home/pi/lib/fpc/3.2.0/ppcarm

This is where "make install" inside the fpc source dir put it. (I always avoid locations outside the home dir...)

Bo Berglund Developer in Sweden

Reply by email

Graeme Geldenhuys
to Bo Berglund: Is it possible to switch Lazarus between using fpc 3.0.4 and 3.2.0 so as to compare the…
Bo Berglund wrote
Is it possible to switch Lazarus between using fpc 3.0.4 and 3.2.0 so as to compare the two easily?

Yes. There is no need for duplicate Lazarus installs. Simply have 2 or more FPC versions installed. I believe the build modes would help switch between the two.

Alternatively, MSEide makes this extremely easy, as can be seen in the attached screenshot. You can assign shortcuts too, so you don't even have to go into the Project Options.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp -------------- next part -------------- A non-text attachment was scrubbed... Name: MSEide_multiple_FPC_versions.png Type: image/png Size: 16680 bytes Desc: not available URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200622/bbffabf3/attachment-0001.png>

Reply by email

Bo Berglund
to Graeme Geldenhuys
Graeme Geldenhuys wrote 7 lines
On 21/06/2020 6:18 am, Bo Berglund via lazarus wrote: > Is it possible to switch Lazarus between using fpc 3.0.4 and 3.2.0 so > as to compare the two easily? Yes. There is no need for duplicate Lazarus installs. Simply have 2 or more FPC versions installed. I believe the build modes would help switch between the two.

Still I seem not to understand this...
I do have two fpc versions installed (3.0.4 and 3.2.0).

But I cannot find any setting for compiler in
Project/Project_Options/Compiler_Options/Build_Modes I only see these items there:
- Other unit files
- Include files
- Libraries
- Unit output directory
- Target file name
- Apply conventions (a checkbox)
- Other sorces
- Debugger path addition

And now I have installed Lazarus 2.0.10 and it *requires* fpc 3.2.0 in order to be able to install packages etc (rebuilding itself). So I have set Lazarus 2.0.10 to use the newly installed fpc 3.2.0.

Does this mean that I also have to build all my projects using fpc 3.2.0?

Or do I have to create a new Lazarus instance shortcut using a different pcp directory where I have set the compiler to be 3.0.4? That would make it impossible to install the packages I need since such a settings stops Lazarus from rebuilding itself (it needs fpc 3.2.0 for that)

I cannot find any *project level* settings in Lazarus that allows me to set the compiler to use for the individual project... (See above about the suggested Build Modes)

So how can I cope with this?
Is it not possible to *easily* switch between two different fpc versions when building ones project?

How can Lazarus be used for cross-compiling in such a case? (I never got cross compile to work when I tried it years back, so I always work on the target platform for that reason)

Alternatively, MSEide makes this extremely easy, as can be seen in the attached screenshot. You can assign shortcuts too, so you don't even have to go into the Project Options.

Is MSEide a replacement for Lazarus?
I really do not want to go down the path of learning a new dev tool...

Bo Berglund Developer in Sweden

Reply by email

Jesus R.
to Bo Berglund

El dom., 5 jul. 2020 a las 0:47, Bo Berglund via lazarus (<

Show quoted text 14 lines
) escribió: But I cannot find any setting for compiler in Project/Project_Options/Compiler_Options/Build_Modes I only see these items there: - Other unit files - Include files - Libraries - Unit output directory - Target file name - Apply conventions (a checkbox) - Other sorces - Debugger path addition <https://lists.lazarus-ide.org/listinfo/lazarus>

See Project/Project_Options/Compiler_Options/compiler_commands in the compiler section there is a combo box for the compiler command, by default it shows "$(CompPath)", but you can specify any compiler you wish for the current build mode, just select it from the list (I guess this list is filled with the Most Recent Compiler List used in
Tools/Options/Enviroment settings).

If you have to switch compilers frequently, everybody has his/her preferred solution, here is mine :)

Just by switching the compiler and rebuilding your project Lazarus will probably want to recompile the LCL and all its dependencies which means overwriting the ppu and o's files compiled with by the previous compiler, and as it happens sometimes this require a cleanup (see run->cleanup and build). But even when a cleanup is not required this takes some time (and if your pc is like mine which still uses bulbs and gears, it usually means long time), so the solution is to edit the LCL package (and all it's package dependencies) and edit the package compiler options/paths/Unit Output Directory (-FU) so after the text "units" (or "lib" depending on the package) insert a \$(FPCVer) (or /$(FPCVer)) macro, in this way the first time that the compiler is switched the LCL and it's dependencies will be rebuilt into its own/specific compiler version directory, resulting in no more overwriting and faster compiling time.

Jesus Reyes A,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200705/7078cf1d/attachment.html>

Reply by email

Bo Berglund
to Jesus R.
"Jesus R. wrote 22 lines
El dom., 5 jul. 2020 a las 0:47, Bo Berglund via lazarus (< >) escribió: > But I cannot find any setting for compiler in > Project/Project_Options/Compiler_Options/Build_Modes > I only see these items there: > - Other unit files > - Include files > - Libraries > - Unit output directory > - Target file name > - Apply conventions (a checkbox) > - Other sorces > - Debugger path addition See Project/Project_Options/Compiler_Options/compiler_commands in the compiler section there is a combo box for the compiler command, by default it shows "$(CompPath)", but you can specify any compiler you wish for the current build mode, just select it from the list (I guess this list is filled with the Most Recent Compiler List used in Tools/Options/Enviroment settings).

In Lazarus 2.0.10 at least this does not exist and is my main concern here. There simply is no item in this dialog concerning the compiler, so your compiler_commands cannot be changed.

LATER:
------
It turns out that in the left side tree view when opening Project/Project_Options the node Compiler_Options is shown at the very bottom but it cannot be expanded by clicking the leading arrow so only the first page is shown.

By accident I double-clicked the title "Compiler Options" and then it expanded and showed a lot more possible options:
- Paths
- Config and Target
- Parsing
- Compilation and linking
- Debugging
- Verbosity
- Messages
- Custom options
- Additions and overrides
- Compiler commands

So only the Paths property page was shown before and the one you refer to was invisible....

Now I will go ahead and create a new build mode with the fpc set to 3.0.4 and see what happens.

Question:
If I create a new build mode and save it and then move over to the Tools menu and set some items there, vill it be saved into the new build mode while keeping the old settings in the default build mode?

I.e. if one create a build mode below the project settings will it be a globally available build mode or just specifically for the currently loaded project?
I don't want to damage the default in any case.

Show quoted text 18 lines
If you have to switch compilers frequently, everybody has his/her preferred solution, here is mine :) Just by switching the compiler and rebuilding your project Lazarus will probably want to recompile the LCL and all its dependencies which means overwriting the ppu and o's files compiled with by the previous compiler, and as it happens sometimes this require a cleanup (see run->cleanup and build). But even when a cleanup is not required this takes some time (and if your pc is like mine which still uses bulbs and gears, it usually means long time), so the solution is to edit the LCL package (and all it's package dependencies) and edit the package compiler options/paths/Unit Output Directory (-FU) so after the text "units" (or "lib" depending on the package) insert a \$(FPCVer) (or /$(FPCVer)) macro, in this way the first time that the compiler is switched the LCL and it's dependencies will be rebuilt into its own/specific compiler version directory, resulting in no more overwriting and faster compiling time.

I am a bit suspicious about this since Lazarus 2.0.10 is specificly requiring fpc 3.2.0 to rebuild itself...
Can there really be a package set built with 3.0.4 in Lazarus 2.0.10?

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 13 lines
Now I will go ahead and create a new build mode with the fpc set to 3.0.4 and see what happens. Question: If I create a new build mode and save it and then move over to the Tools menu and set some items there, vill it be saved into the new build mode while keeping the old settings in the default build mode? I.e. if one create a build mode below the project settings will it be a globally available build mode or just specifically for the currently loaded project? I don't want to damage the default in any case.

So this does not work...

As long as I am in the same Lazarus session I can create several new build modes and then switch between them using the mode switch button in the lower button bar below the main menu.
So far so good.
But when I exit and restart Lazarus the newly created build modes are no longer present...

So do I have to create build modes separately for every project I work with and then save them (in that case how are they saved)? Currently if I just start Lazarus 2.0.10, create the build modes and close Lazarus nothing gets saved.

Must be something *obvious* I am missing here.

Shouldn't there be globally available build modes in Lazarus?

Bo Berglund Developer in Sweden

Reply by email

Mattias Gaertner
to Bo Berglund: On Sun, 5 Jul 2020 01:44:27 -0500, "Jesus R. via lazarus" In Lazarus 2.0.10 at least this…
Show quoted text 7 lines
[...] >See Project/Project_Options/Compiler_Options/compiler_commands in the >compiler section there is a combo box for the compiler command, by >default it shows "$(CompPath)", but you can specify any compiler you >wish for the current build mode, just select it from the list (I >guess this list is filled with the Most Recent Compiler List used in >Tools/Options/Enviroment settings).

And if not simply click on the right browse button and select the fpc or ppcx64 of your choice.

Show quoted text 10 lines
In Lazarus 2.0.10 at least this does not exist and is my main concern here. There simply is no item in this dialog concerning the compiler, so your compiler_commands cannot be changed. LATER: ------ It turns out that in the left side tree view when opening Project/Project_Options the node Compiler_Options is shown at the very bottom but it cannot be expanded by clicking the leading arrow so only the first page is shown.

Never seen that. It is and was always expanded.

Show quoted text 23 lines
By accident I double-clicked the title "Compiler Options" and then it expanded and showed a lot more possible options: - Paths - Config and Target - Parsing - Compilation and linking - Debugging - Verbosity - Messages - Custom options - Additions and overrides - Compiler commands So only the Paths property page was shown before and the one you refer to was invisible.... Now I will go ahead and create a new build mode with the fpc set to 3.0.4 and see what happens. Question: If I create a new build mode and save it and then move over to the Tools menu and set some items there, vill it be saved into the new build mode while keeping the old settings in the default build mode?

The build mode only contains the compiler options.

I.e. if one create a build mode below the project settings will it be a globally available build mode or just specifically for the currently loaded project?

project only.

Show quoted text 5 lines
I don't want to damage the default in any case. [...] I am a bit suspicious about this since Lazarus 2.0.10 is specificly requiring fpc 3.2.0 to rebuild itself... Can there really be a package set built with 3.0.4 in Lazarus 2.0.10?

Usually the package is built for either the IDE or the current project, so a package uses the IDE or project compiler.

Mattias

Reply by email

Bo Berglund
to Mattias Gaertner
Mattias Gaertner wrote 10 lines
On Sun, 05 Jul 2020 10:40:11 +0200 Bo Berglund via lazarus wrote: >[...] > >See Project/Project_Options/Compiler_Options/compiler_commands in the > >compiler section there is a combo box for the compiler command, by > >default it shows "$(CompPath)", but you can specify any compiler you > >wish for the current build mode, just select it from the list (I > >guess this list is filled with the Most Recent Compiler List used in > >Tools/Options/Enviroment settings).

Except there is nothing real to select from. The dropdown shows the selected item as:
$(CompPath)

And then there are a few extra paths to select from, all non-existing on the system...

And if not simply click on the right browse button and select the fpc or ppcx64 of your choice.

I guess I could do that provided it stays put...

Show quoted text 6 lines
> It turns out that in the left side tree view when opening > Project/Project_Options the node Compiler_Options is shown at the very > bottom but it cannot be expanded by clicking the leading arrow so only > the first page is shown. Never seen that. It is and was always expanded.

It was hidden straight out of the box after I installed Lazarus. Now after I have once doubleclicked the node name it is always expanded when I reach this setting...

Bo Berglund Developer in Sweden

Reply by email

Graeme Geldenhuys
to Bo Berglund: On Mon, 22 Jun 2020 17:44:20 +0100, Graeme Geldenhuys via lazarus Still I seem not to…
Bo Berglund wrote 5 lines
Still I seem not to understand this... I do have two fpc versions installed (3.0.4 and 3.2.0). But I cannot find any setting for compiler in Project/Project_Options/Compiler_Options/Build_Modes

It's been a while. I thought there was a setting or macro in the Build Modes dialog. If not, then you need to use "Tools -> Options -> Environment > Compiler Executable" and keep selecting a different version. Hence I said MSEide has always done this better - even via a shortcut to toggle between compiler versions.

Also, I have adopted a directory hierarchy years ago, where multiple versions are easily supported.
Then make sure your ~/.fpc.cfg file is configured to handle multiple versions.

My directory layout:

/data/devel/fpc-2.6.4/
- src/
- x86_64-linux
/data/devel/fpc-3.0.4/
- src/
- x86_64-linux
/data/devel/fpc-3.2.0/
- src/
- x86_64-linux

A snippet from my ~/.fpc.cfg file where I use macros for the version:

# searchpath for units and other system dependent things -Fu/data/devel/fpc-$fpcversion/$fpctarget/lib/fpc/$fpcversion/units/$fpctarget -Fu/data/devel/fpc-$fpcversion/$fpctarget/lib/fpc/$fpcversion/units/$fpctarget/* -Fu/data/devel/fpc-$fpcversion/$fpctarget/lib/fpc/$fpcversion/units/$fpctarget/rtl

Saying that, I think Lazarus IDE looks for a fpc.cfg file in the same directory as the fpc.exe executable you selected. So in that case, maybe the ~/.fpc.cfg modifications are not needed for Lazarus. *shrug*

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email