Sign in Join

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

Mailing lists / lazarus / 2010-11

How to use environment variables in lazarus IDE config?

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Bo Berglund

I would like to specify things like the base location of files using environment variables rather than entering full paths.

In Delphi this can be done by using the $(varname) construct, but this is apparently not supported by Lazarus.
I googled my way through and found a reference to using $Env(varname) instead.

But when I use this in my lazarus (to specify the location of the FPC compiler for instance), lazarus complains that it cannot find the executable.

I entered the following as the FPC compiler path:

$Env(FPCBASE)\2.4.2\bin\i386-Win32\fpc.exe

The env var FPCBASE is set to C:\Programs\fpc

But Lazarus complains.. :-(

Is it not allowed to use environment variables in lazarus IDE??

Bo Berglund

Reply by email

Mattias Gaertner
to Bo Berglund
Show quoted text 11 lines
I would like to specify things like the base location of files using environment variables rather than entering full paths. In Delphi this can be done by using the $(varname) construct, but this is apparently not supported by Lazarus. I googled my way through and found a reference to using $Env(varname) instead. But when I use this in my lazarus (to specify the location of the FPC compiler for instance), lazarus complains that it cannot find the executable.

I implemented resolving macros for the environment option compiler file name.

Use on your on risk.
There is currently no real circle detection for macros, so you can create endless loops. There is already a bug report.

I entered the following as the FPC compiler path: $Env(FPCBASE)\2.4.2\bin\i386-Win32\fpc.exe

Should work now.

Mattias

Reply by email

Bo Berglund
to Mattias Gaertner
Mattias Gaertner wrote 21 lines
On Tue, 30 Nov 2010 17:48:47 +0100 Bo Berglund wrote: > I would like to specify things like the base location of files using > environment variables rather than entering full paths. > > In Delphi this can be done by using the $(varname) construct, but this > is apparently not supported by Lazarus. > I googled my way through and found a reference to using $Env(varname) > instead. > > But when I use this in my lazarus (to specify the location of the FPC > compiler for instance), lazarus complains that it cannot find the > executable. I implemented resolving macros for the environment option compiler file name. Use on your on risk. There is currently no real circle detection for macros, so you can create endless loops. There is already a bug report.

Macros?? I am talking about how to use environment variables in file specifications in Lazarus, not about macros...

Like for example in Delphi I have this in my project path to define the location of Indy. I have several versions of Indy on my PC because they change Indy around such that old code breaks severely if using the new Indy versions:

$(INDY10)\System
$(INDY10)\Protocols
$(INDY10)\Core

In another project I can have:

$(INDY9)\System
$(INDY9)\Protocols
$(INDY9)\Core

This way no matter where the individual developer has placed his Indy files he can use the env var to set the location and the project file (*.dof) does not have to be changed when retrieved from CVS. It simply just works...

There are also other uses, like in lazarus to specify which FPC to use..

Show quoted text 6 lines
> I entered the following as the FPC compiler path: > > $Env(FPCBASE)\2.4.2\bin\i386-Win32\fpc.exe Should work now.

"Now" meaning what? Do I need to grab a newer version of lazarus and rebuild it?

Bo Berglund Developer in Sweden

Reply by email

Sven Barth
to Bo Berglund
Bo Berglund wrote 28 lines
On Tue, 30 Nov 2010 18:35:48 +0100, Mattias Gaertner wrote: > On Tue, 30 Nov 2010 17:48:47 +0100 > Bo Berglund wrote: > >> I would like to specify things like the base location of files using >> environment variables rather than entering full paths. >> >> In Delphi this can be done by using the $(varname) construct, but this >> is apparently not supported by Lazarus. >> I googled my way through and found a reference to using $Env(varname) >> instead. >> >> But when I use this in my lazarus (to specify the location of the FPC >> compiler for instance), lazarus complains that it cannot find the >> executable. > > I implemented resolving macros for the environment option compiler file > name. > > Use on your on risk. > There is currently no real circle detection for macros, so you can > create endless loops. There is already a bug report. Macros?? I am talking about how to use environment variables in file specifications in Lazarus, not about macros...

Those $(Something) or $Something() variables are called marcos. See also: http://wiki.lazarus.freepascal.org/IDE_Macros_in_paths_and_filenames

Show quoted text 10 lines
> >> I entered the following as the FPC compiler path: >> >> $Env(FPCBASE)\2.4.2\bin\i386-Win32\fpc.exe > > Should work now. "Now" meaning what? Do I need to grab a newer version of lazarus and rebuild it?

"Now" means that it was applied to trunk, so you either need to update using svn or you need to wait until a snapshot containing the changed code is available (usually on the next day).

Regards,
Sven

Reply by email

Mattias Gaertner
to Bo Berglund: On Tue, 30 Nov 2010 18:35:48 +0100, Mattias Gaertner Macros?? I am talking about how to…
Show quoted text 47 lines
On Tue, 30 Nov 2010 18:35:48 +0100, Mattias Gaertner wrote: >On Tue, 30 Nov 2010 17:48:47 +0100 >Bo Berglund wrote: > >> I would like to specify things like the base location of files using >> environment variables rather than entering full paths. >> >> In Delphi this can be done by using the $(varname) construct, but this >> is apparently not supported by Lazarus. >> I googled my way through and found a reference to using $Env(varname) >> instead. >> >> But when I use this in my lazarus (to specify the location of the FPC >> compiler for instance), lazarus complains that it cannot find the >> executable. > >I implemented resolving macros for the environment option compiler file >name. > >Use on your on risk. >There is currently no real circle detection for macros, so you can >create endless loops. There is already a bug report. Macros?? I am talking about how to use environment variables in file specifications in Lazarus, not about macros... Like for example in Delphi I have this in my project path to define the location of Indy. I have several versions of Indy on my PC because they change Indy around such that old code breaks severely if using the new Indy versions: $(INDY10)\System $(INDY10)\Protocols $(INDY10)\Core In another project I can have: $(INDY9)\System $(INDY9)\Protocols $(INDY9)\Core This way no matter where the individual developer has placed his Indy files he can use the env var to set the location and the project file (*.dof) does not have to be changed when retrieved from CVS. It simply just works...

... and Lazarus does not need this one variable per version, because it has versions in the lpk files. If a project needs Indy9 it can be specified in the dependency. When you give the project to another developer he does not need to set his environment options to your names and he will get a proper error message if the package is not there, instead of "unit not found".

There are also other uses, like in lazarus to specify which FPC to use..

For cross compiling you can use one compiler: fpc.

For several FPC versions: You can specify the compiler per project. And with build modes you can switch easily. (At the moment this not yet passed to the codetools. This is a ToDo.)

Show quoted text 8 lines
>> I entered the following as the FPC compiler path: >> >> $Env(FPCBASE)\2.4.2\bin\i386-Win32\fpc.exe > >Should work now. "Now" meaning what? Do I need to grab a newer version of lazarus and rebuild it?

Yes. Please test.

Mattias

Reply by email

Bo Berglund
to Mattias Gaertner
Mattias Gaertner wrote 11 lines
> >> I entered the following as the FPC compiler path: > >> > >> $Env(FPCBASE)\2.4.2\bin\i386-Win32\fpc.exe > > > >Should work now. > > "Now" meaning what? Do I need to grab a newer version of lazarus and > rebuild it? Yes. Please test.

Will do.
My new lazarus is trunk from SVN so I guess I just have to update from the server and rebuild lazarus?

Bo Berglund Developer in Sweden

Reply by email

Sven Barth
to Bo Berglund
Bo Berglund wrote 18 lines
On Wed, 1 Dec 2010 10:12:00 +0100, Mattias Gaertner wrote: >>>> I entered the following as the FPC compiler path: >>>> >>>> $Env(FPCBASE)\2.4.2\bin\i386-Win32\fpc.exe >>> >>> Should work now. >> >> "Now" meaning what? Do I need to grab a newer version of lazarus and >> rebuild it? > > Yes. Please test. > Will do. My new lazarus is trunk from SVN so I guess I just have to update from the server and rebuild lazarus?

That is correct.

Regards,
Sven

Reply by email