public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* setting Win32 environment variables in Cygwin
@ 2005-07-20 19:21 Alex Goldman
  2005-07-20 21:47 ` Mark Hadfield
  2005-07-21 10:40 ` Andrew Schulman
  0 siblings, 2 replies; 4+ messages in thread
From: Alex Goldman @ 2005-07-20 19:21 UTC (permalink / raw)
  To: cygwin

When I execute a *.bat file containing lines like

Set FOO=12345

FOO does not show up in the environment of the Cygwin shell. Further,
if I execute Win32 programs that access the environment, they can not
see FOO either.

Specifically, I need to do

Set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH%
Set INCLUDE=C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
Set LIB=C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\lib;C:\Program Files\Microsoft Visual C++ Toolkit
2003\lib;%LIB%

So that VC++ will run properly from the command line. Any suggestions?

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: setting Win32 environment variables in Cygwin
  2005-07-20 19:21 setting Win32 environment variables in Cygwin Alex Goldman
@ 2005-07-20 21:47 ` Mark Hadfield
  2005-07-20 23:51   ` Igor Pechtchanski
  2005-07-21 10:40 ` Andrew Schulman
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Hadfield @ 2005-07-20 21:47 UTC (permalink / raw)
  To: cygwin

Alex Goldman wrote:
> When I execute a *.bat file containing lines like
> 
> Set FOO=12345
> 
> FOO does not show up in the environment of the Cygwin shell. Further,
> if I execute Win32 programs that access the environment, they can not
> see FOO either.

It's not clear what you're doing from your description, but if you are 
opening a Cygwin shell (eg bash), invoking cmd.exe to process the batch 
file and returning to bash, then you certainly won't see FOO in bash.

> Specifically, I need to do
> 
> Set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH%
> Set INCLUDE=C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
> Set LIB=C:\Program Files\Microsoft Visual Studio .NET
> 2003\Vc7\lib;C:\Program Files\Microsoft Visual C++ Toolkit
> 2003\lib;%LIB%
> 
> So that VC++ will run properly from the command line. Any suggestions?

There was a question in the last day or two about running Digital/Compaq 
Visual Fortran from a Cygwin shell. My answer pretty much applies here.

   http://cygwin.com/ml/cygwin/2005-07/msg00849.html

I've also expounded on this in the past, mostly in connection with 
Fortran compilers. A bit of judicious searching might uncover some more 
info.

You should write bash commands to set the environment variables. You can 
invoke them at the prompt or bundle them in a bash function and invoke 
that. (It's no good putting them in a shell script and processing it 
with /bin/bash: it'll all be forgotten when the subprocess exits.) You 
do have to be careful with characters that need quoting (backslash, 
semi-colon, space). You also have to allow for the fact that PATH is 
automagically converted between Unix and Windows forms, but the others 
aren't. The above link gives an example of how to deal with all these 
issues.

By the way, do you really want to *prepend* entries to the LIB and 
INCLUDE environment variables (as opposed to starting from scratch)? If 
so, you'd better make sure the existing variables are in the Windows 
format expected by your compiler. Ending up with INCLUDE set to 
something like:

C:\Program Files\Microsoft Visual C++ Toolkit 
2003\include;/usr/local/include:/usr/include

would not be cool.



-- 
Mark Hadfield          "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: setting Win32 environment variables in Cygwin
  2005-07-20 21:47 ` Mark Hadfield
@ 2005-07-20 23:51   ` Igor Pechtchanski
  0 siblings, 0 replies; 4+ messages in thread
From: Igor Pechtchanski @ 2005-07-20 23:51 UTC (permalink / raw)
  To: Mark Hadfield; +Cc: cygwin

On Thu, 21 Jul 2005, Mark Hadfield wrote:

> Alex Goldman wrote:
> > When I execute a *.bat file containing lines like
> >
> > Set FOO=12345
> >
> > FOO does not show up in the environment of the Cygwin shell. Further,
> > if I execute Win32 programs that access the environment, they can not
> > see FOO either.
>
> [snip]
> You should write bash commands to set the environment variables. You can
> invoke them at the prompt or bundle them in a bash function and invoke that.
> (It's no good putting them in a shell script and processing it with /bin/bash:
> it'll all be forgotten when the subprocess exits.)

But you could "source" the script (using either "source" or ".")...

> [snip]
> By the way, do you really want to *prepend* entries to the LIB and INCLUDE
> environment variables (as opposed to starting from scratch)? If so, you'd
> better make sure the existing variables are in the Windows format expected by
> your compiler. Ending up with INCLUDE set to something like:
>
> C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;/usr/local/include:/usr/include
>
> would not be cool.

Beware of setting LIB -- it may screw up Perl.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: setting Win32 environment variables in Cygwin
  2005-07-20 19:21 setting Win32 environment variables in Cygwin Alex Goldman
  2005-07-20 21:47 ` Mark Hadfield
@ 2005-07-21 10:40 ` Andrew Schulman
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Schulman @ 2005-07-21 10:40 UTC (permalink / raw)
  To: cygwin

> Specifically, I need to do
> 
> Set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH%
> Set INCLUDE=C:\Program Files\Microsoft Visual C++ Toolkit
> 2003\include;%INCLUDE% Set LIB=C:\Program Files\Microsoft Visual Studio
> .NET 2003\Vc7\lib;C:\Program Files\Microsoft Visual C++ Toolkit
> 2003\lib;%LIB%
> 
> So that VC++ will run properly from the command line. Any suggestions?

Since these variables are to be used by a Windows app, it would make most
sense to set them in Windows.  Then they'll be available to all Windows
apps (including others that might start VC++), and also in Cygwin.  In XP,
you can use the so-well-hidden-it's-almost-gone environment variables pane: 
right click on my computer, Properties, Advanced, Environment Variables. 
You may find it easier just to enter them directly into the registry: 
HKCU\Environment for user-specific variables, or
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment for
system-wide variables.

For path variables that you want to use in both Windows and Cygwin, there is
a path conversion problem, as Igor says.  If you're using VC++ and not gcc,
then you can just leave INCLUDE et al. as Windows-format paths.  But if you
want to launch both from Cygwin, then you have a problem, because either
path format (Windows or Cygwin) will be wrong for one of them.  I guess
what's needed is to put the paths into Cygwin format, and write a wrapper
script for VC++, that converts them back to Windows format first. 
Fortunately cygpath(1) can make these conversions for you.

Good luck,
Andrew.



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-07-21  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-20 19:21 setting Win32 environment variables in Cygwin Alex Goldman
2005-07-20 21:47 ` Mark Hadfield
2005-07-20 23:51   ` Igor Pechtchanski
2005-07-21 10:40 ` Andrew Schulman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).