Kelly O'Hair's Weblog (blogs.sun.com)
Friday Aug 14, 2009
Windows Visual Studio Stupid Pet Trick of the Day
Sept 1, 2009: Updated script, now works with MKS shell environments.
Re-posting this blog about a shell script interface to the Visual Studio environment setting files vsvars32.bat or vcvars32.bat. Mine is called vsvars.sh. This was my Windows Visual Studio Stupid Pet Trick of the Day, but it's turned into the stupid pet trick of the year. It's mostly for you CYGWIN Visual Studio Users.
The vsvars.sh script will exec a Windows command shell, have it spit out the environment variables it sets, and then it echos out shell environment variable setting commands. And here it is:
Running "vsvars -v7" will get you the settings for Visual Studio 2003:
Nasty looking stuff, but matches what the official Visual Studio vcvars32.bat (or vsvars32.bat) files do to the Windows command shell environment. Note that not all these must be defined in the environment before running Visual Studio, depending on what you are running the critical ones are: INCLUDE, LIB, PATH, LIBPATH, VCINSTALLDIR, VSINSTALLDIR, MSVCDIR, and DEVENVDIR. The first ones INCLUDE, LIB, PATH, and LIBPATH are needed by the compiler, LIBPATH for the newer compilers. The others may be needed by other Visual Studio tools.
The nice thing is that you can use it in a shell environment like so:
eval `vcvars.sh -v7`
By default it should figure out what kind of shell you are using and do the right thing. Use the -help option to see all the options:
It works pretty slick... although I can't possibly test it in all situations.
This will probably be hooked into the JDK builds at some point, or provided with those sources.
-kto
Posted at 11:24AM Aug 14, 2009 by kto in Java | Comments[4]












Thank you!
Posted by Neal Gafter on April 15, 2009 at 06:25 AM PDT #
Now you guys work for Oracle now... :)
Ain't it time you borrowed from the icedtea playbook and built openjdk with a free toolchain like gcc?
Cross compile from Solaris using mingw/wine headers?
Posted by Pete on April 23, 2009 at 10:55 PM PDT #
Pete - once you have a working patch, please add it to bugs.openjdk.java.net.
Posted by Dalibor Topic on April 23, 2009 at 11:01 PM PDT #
The file vcvars32.bat was required to build some Teamcenter Enginering .c programs and I was wondering what the vcvars32.bat (or vsvar32.bat) file was all about. Googling for vcvars32.bat did not yield a downloadable example. Since you posted an example in the output snippet, now I know basically what vcvars32.bat does without having to pay $$$ for Visual Studio and installing or trying to install a education my old (student) edition.
Hopefully, I'll be able to get by with Eclipse or gcc since the files are .c (i.e. they're not c++ or c# files so I don't know why they are requiring Visual C++ or Visual Studio).
Thanks for for showing the way and the guts of the vcvars32.bat.
Posted by David on May 26, 2009 at 01:14 PM PDT #