Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Using environment variables
Using environment variables [message #59199] Tue, 21 January 2003 11:59 Go to next message
Eclipse UserFriend
Originally posted by: nomail.bob.com

It looks like this is still in plan but is it currently possible to specify
environment variables to used in the make command. Our current makefiles
havily use defined environment variables, however when I try to run this
with CDT the variables are not calculated. For instance if I set up an
external program, point it to echo and provide %SBD% as an argument (a
pre-defined variable) the program will return %SBD% not the required value
of that variable.
This is on win2000, sp3 with F1 of cdt installed, and now working thankfully
Cheers In advance
Steve
Re: Using environment variables [message #59276 is a reply to message #59199] Tue, 21 January 2003 15:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ash371952.hotmail.com

You can easily test it.
Create simple C project, go to project properties : C/C++ projects : Build
command and type
cmd /c set
Then Open Make Targets view and for this project create target " " (1
space), then build this target. You will see in C-build view all environment
variables that are transferred to make. It should be inherited from IDE.

Alex.

"Stephen Cox" <nomail@bob.com> wrote in message
news:b0jt2k$pfe$1@rogue.oti.com...
> It looks like this is still in plan but is it currently possible to
specify
> environment variables to used in the make command. Our current makefiles
> havily use defined environment variables, however when I try to run this
> with CDT the variables are not calculated. For instance if I set up an
> external program, point it to echo and provide %SBD% as an argument (a
> pre-defined variable) the program will return %SBD% not the required value
> of that variable.
> This is on win2000, sp3 with F1 of cdt installed, and now working
thankfully
> Cheers In advance
> Steve
>
>
Re: Using environment variables [message #59352 is a reply to message #59276] Wed, 22 January 2003 04:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nomail.bob.com

cmd /c set does give me the correct list of environment variables from
within eclipse including
SBD=T:\cs
however using the same idea
adding echo to the project make command and using %SBD% as the build target
(or indeed setting the build command to echo %SBD% and using " " (space))
produces
echo %SBD%
%SBD%
which differs from the command line
echo %SBD%
T:\cs
which makes me think that make is not picking up my environment variables
either. The error that I am seeing from within eclipse is the same as the
error I would expect if SBD was not set and I tried to invoke make from the
command line.
Thanks again for your help
Steve





"Alex Chapiro" <ash371952@hotmail.com> wrote in message
news:b0k9v6$2mg$1@rogue.oti.com...
> You can easily test it.
> Create simple C project, go to project properties : C/C++ projects : Build
> command and type
> cmd /c set
> Then Open Make Targets view and for this project create target " " (1
> space), then build this target. You will see in C-build view all
environment
> variables that are transferred to make. It should be inherited from IDE.
>
> Alex.
>
> "Stephen Cox" <nomail@bob.com> wrote in message
> news:b0jt2k$pfe$1@rogue.oti.com...
> > It looks like this is still in plan but is it currently possible to
> specify
> > environment variables to used in the make command. Our current makefiles
> > havily use defined environment variables, however when I try to run this
> > with CDT the variables are not calculated. For instance if I set up an
> > external program, point it to echo and provide %SBD% as an argument (a
> > pre-defined variable) the program will return %SBD% not the required
value
> > of that variable.
> > This is on win2000, sp3 with F1 of cdt installed, and now working
> thankfully
> > Cheers In advance
> > Steve
> >
> >
>
>
Re: Using environment variables [message #59377 is a reply to message #59352] Wed, 22 January 2003 07:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ash371952.hotmail.com

> adding echo to the project make command and using %SBD% as the build
target
> (or indeed setting the build command to echo %SBD% and using " " (space))
> produces
> echo %SBD%
> %SBD%
> which differs from the command line
> echo %SBD%
> T:\cs

Try to use in make file
echo $(SBD)
instead of
echo %SBD%

Alex
Re: Using environment variables [message #59525 is a reply to message #59377] Thu, 23 January 2003 06:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nomail.bob.com

echo $SBD gives me $SBD
echo $(SBD) gives me $(SBD)
Any other hints?

"Alex Chapiro" <ash371952@hotmail.com> wrote in message
news:b0m1nf$47f$1@rogue.oti.com...
> > adding echo to the project make command and using %SBD% as the build
> target
> > (or indeed setting the build command to echo %SBD% and using " "
(space))
> > produces
> > echo %SBD%
> > %SBD%
> > which differs from the command line
> > echo %SBD%
> > T:\cs
>
> Try to use in make file
> echo $(SBD)
> instead of
> echo %SBD%
>
> Alex
>
>
Re: Using environment variables [message #59547 is a reply to message #59525] Thu, 23 January 2003 06:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: johan.nosp.m.appeal.se

Stephen Cox wrote:
> echo $SBD gives me $SBD
> echo $(SBD) gives me $(SBD)
> Any other hints?

echo ${BSD}
Re: Using environment variables [message #59570 is a reply to message #59525] Thu, 23 January 2003 07:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ash371952.hotmail.com

echo $SBD is positively a bad idea :-))
echo $(SBD) works for me.
Are you using cygwin? If so, I'll try to test the same thing in this
environment.
What I know exactly is that IDE uses one and the same mechanism for
launching any application, so if it passes SBD value correctly to cmd, on
the same way it passes SBD to any other application, and make shouldn't be
an exception.
Anyway, I'll try to play with it a bit more and let you know.



"Stephen Cox" <nomail@bob.com> wrote in message
news:b0ogp1$t0j$1@rogue.oti.com...
> echo $SBD gives me $SBD
> echo $(SBD) gives me $(SBD)
> Any other hints?
>
> "Alex Chapiro" <ash371952@hotmail.com> wrote in message
> news:b0m1nf$47f$1@rogue.oti.com...
> > > adding echo to the project make command and using %SBD% as the build
> > target
> > > (or indeed setting the build command to echo %SBD% and using " "
> (space))
> > > produces
> > > echo %SBD%
> > > %SBD%
> > > which differs from the command line
> > > echo %SBD%
> > > T:\cs
> >
> > Try to use in make file
> > echo $(SBD)
> > instead of
> > echo %SBD%
> >
> > Alex
> >
> >
>
>
Re: Using environment variables [message #59615 is a reply to message #59525] Thu, 23 January 2003 12:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ash371952.hotmail.com

BTW, if I use the name of unknown environment variable, echo prints nothing.
So if my Makefile has something like that:
foo:

echo $(BLA_BLA_BLA) HO_HO_HO

then running "make foo"

prints just

HO_HO_HO

(I didn't define environment variable BLA_BLA_BLA).

You wrote that you see something like:

$(BLA_BLA_BLA) HO_HO_HO

I cannot understand this result.



"Stephen Cox" <nomail@bob.com> wrote in message
news:b0ogp1$t0j$1@rogue.oti.com...
> echo $SBD gives me $SBD
> echo $(SBD) gives me $(SBD)
> Any other hints?
>
> "Alex Chapiro" <ash371952@hotmail.com> wrote in message
> news:b0m1nf$47f$1@rogue.oti.com...
> > > adding echo to the project make command and using %SBD% as the build
> > target
> > > (or indeed setting the build command to echo %SBD% and using " "
> (space))
> > > produces
> > > echo %SBD%
> > > %SBD%
> > > which differs from the command line
> > > echo %SBD%
> > > T:\cs
> >
> > Try to use in make file
> > echo $(SBD)
> > instead of
> > echo %SBD%
> >
> > Alex
> >
> >
>
>
Re: Using environment variables [message #59734 is a reply to message #59615] Fri, 24 January 2003 05:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nomail.bob.com

I am using cygwin. echo is coming from /usr/cygbin/echo on windows 2000
service pack 3. I'm not sure what is going on, but I'm sure echo is not
being fed the correct environment variables within eclipse
From the command prompt:
echo $(SBD)
$(SBD)
echo %SBD%
T:\cs
echo %BOB% (doesnt exist)
%BOB%
echo $(BOB)
$(BOB)

From within Eclipse:
which echo
/usr/bin/echo
echo $(SBD)
$(SBD)
echo %SBD%
%SBD%
echo %BOB%
%BOB%
echo $(BOB)
$(BOB)

oh and just to note {} dont work either, they just get removed
echo ${SBD}
$SBD

also set SBD from the command prompt returns
SBD=T:\cs
set SBD from within eclipse does not return anything at all
where as set BOB from the command prompt returns
Environment variable BOB not defined

Thanks again for the help


"Alex Chapiro" <ash371952@hotmail.com> wrote in message
news:b0p875$i77$1@rogue.oti.com...
> BTW, if I use the name of unknown environment variable, echo prints
nothing.
> So if my Makefile has something like that:
> foo:
>
> echo $(BLA_BLA_BLA) HO_HO_HO
>
> then running "make foo"
>
> prints just
>
> HO_HO_HO
>
> (I didn't define environment variable BLA_BLA_BLA).
>
> You wrote that you see something like:
>
> $(BLA_BLA_BLA) HO_HO_HO
>
> I cannot understand this result.
>
>
>
> "Stephen Cox" <nomail@bob.com> wrote in message
> news:b0ogp1$t0j$1@rogue.oti.com...
> > echo $SBD gives me $SBD
> > echo $(SBD) gives me $(SBD)
> > Any other hints?
> >
> > "Alex Chapiro" <ash371952@hotmail.com> wrote in message
> > news:b0m1nf$47f$1@rogue.oti.com...
> > > > adding echo to the project make command and using %SBD% as the build
> > > target
> > > > (or indeed setting the build command to echo %SBD% and using " "
> > (space))
> > > > produces
> > > > echo %SBD%
> > > > %SBD%
> > > > which differs from the command line
> > > > echo %SBD%
> > > > T:\cs
> > >
> > > Try to use in make file
> > > echo $(SBD)
> > > instead of
> > > echo %SBD%
> > >
> > > Alex
> > >
> > >
> >
> >
>
>
Re: Using environment variables [message #59757 is a reply to message #59734] Fri, 24 January 2003 09:29 Go to previous message
Eclipse UserFriend
Originally posted by: ash371952.hotmail.com

"Stephen Cox" <nomail@bob.com> wrote in message
news:b0r385$n6v$1@rogue.oti.com...
> I am using cygwin. echo is coming from /usr/cygbin/echo on windows 2000
> service pack 3. I'm not sure what is going on, but I'm sure echo is not
> being fed the correct environment variables within eclipse
> From the command prompt:
> echo $(SBD)
> $(SBD)
> echo %SBD%
> T:\cs
> echo %BOB% (doesnt exist)
> %BOB%
> echo $(BOB)
> $(BOB)

Yes, that's correct. Echo prints the text without substitution (%BOB% for
instance) if it does not recognize this format. I tried yesterday night the
same example on cygwin Win2000 computer and everything worked well. As far
as in your case for any macro format echo never substitutes macros, it seems
to me that it would also fail to substitute %PATH% or $(PATH) or $PATH as
well. Looks like it doesn't understand any macro substitution format. Could
you please try to use absolute path for echo command in your make file?
Could you please also try it for PATH ? In Windows echo is an embedded
command and I guess overrule the path call order.
>
> From within Eclipse:
> which echo

I think "which" just searches executable with this name in the path order.
If command shell then runs embedded version, you don't know about that.
So please try full path name to call cygwin echo command.

> /usr/bin/echo
> echo $(SBD)
> $(SBD)
> echo %SBD%
> %SBD%
> echo %BOB%
> %BOB%
> echo $(BOB)
> $(BOB)
>
> oh and just to note {} dont work either, they just get removed
> echo ${SBD}
> $SBD
>
> also set SBD from the command prompt returns
> SBD=T:\cs
> set SBD from within eclipse does not return anything at all
> where as set BOB from the command prompt returns
> Environment variable BOB not defined
>
> Thanks again for the help
>
>
> "Alex Chapiro" <ash371952@hotmail.com> wrote in message
> news:b0p875$i77$1@rogue.oti.com...
> > BTW, if I use the name of unknown environment variable, echo prints
> nothing.
> > So if my Makefile has something like that:
> > foo:
> >
> > echo $(BLA_BLA_BLA) HO_HO_HO
> >
> > then running "make foo"
> >
> > prints just
> >
> > HO_HO_HO
> >
> > (I didn't define environment variable BLA_BLA_BLA).
> >
> > You wrote that you see something like:
> >
> > $(BLA_BLA_BLA) HO_HO_HO
> >
> > I cannot understand this result.
> >
> >
> >
> > "Stephen Cox" <nomail@bob.com> wrote in message
> > news:b0ogp1$t0j$1@rogue.oti.com...
> > > echo $SBD gives me $SBD
> > > echo $(SBD) gives me $(SBD)
> > > Any other hints?
> > >
> > > "Alex Chapiro" <ash371952@hotmail.com> wrote in message
> > > news:b0m1nf$47f$1@rogue.oti.com...
> > > > > adding echo to the project make command and using %SBD% as the
build
> > > > target
> > > > > (or indeed setting the build command to echo %SBD% and using " "
> > > (space))
> > > > > produces
> > > > > echo %SBD%
> > > > > %SBD%
> > > > > which differs from the command line
> > > > > echo %SBD%
> > > > > T:\cs
> > > >
> > > > Try to use in make file
> > > > echo $(SBD)
> > > > instead of
> > > > echo %SBD%
> > > >
> > > > Alex
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Previous Topic:Debugging (Cygwin, MIPS toolchain)
Next Topic:Building Error with gcc...
Goto Forum:
  


Current Time: Thu May 01 10:16:29 EDT 2025

Powered by FUDForum. Page generated in 0.24110 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top