[vox-tech] [OT] Running/compiling win32 executables from cygwin

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Fri Dec 15 18:45:54 PST 2006


p at dirac.org wrote:
> Is it possible to run win32 executables from a cygwin xterm?

I do it all the time.

> I'm trying to figure out how to compile stuff using VC++ from the command
> line at work.  When using the "command prompt", I need to run a batch file
> to set up the environment:
> 
>    $ c:\Program Files\Microsoft ... 2003\Common7\Tools\vsvars32.bat
> 
>    cl /EHsc foo.cpp
>    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
>    Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
> 
>    foo.cpp
>    Microsoft (R) Incremental Linker Version 7.10.3077
>    Copyright (C) Microsoft Corporation.  All rights reserved.
> 
>    /out:foo.exe
>    foo.obj
> 
> 
> However, from cygwin, it appears to fail silently:
> 
>    $ vcvars32.bat
> 
>    c:\Documents and Settings\psalzman\home\programming\cmdline>"c:\Program
>    Files\Microsoft Visual Studio .NET 2003\Common7\
>    Tools\vsvars32.bat"
>    Setting environment for using Microsoft Visual Studio .NET 2003 tools.
>    (If you have another version of Visual Studio or Visual C++ installed and
>    wish to use its tools from the command line, run vcvars32.bat for that
>    version.)
> 
>    $ cl foo.cpp
>    $ ls
>    Makefile*  foo.cpp
> 
> I'd rather work in cygwin since I'm more comfortable and familiar with that
> environment.  Is it possible to use cl.exe from cygwin?  Maybe it's a matter
> of environment variables?

Batch files are normally "sourced" by cmd.exe, and given the name of the
batch file you are dealing with, it sounds like it is modifying
environment variables for the VC toolchain.

> Also, does the "command prompt" have an equivalent to a .bashrc?  If I
> *have* to use it to do command line compiling, I'd rather change my prompt
> to "$ " and run vsvars32.bat automatically since the only time I'll be using
> the "command prompt" is when I'm compiling my programs.

Either translate vcvars32.bat to bash, or setup a .BAT file that
invokes both in sequence and then invoke that batch file from bash,
something like:

---vc---
#!/bin/sh
cmd /C MYVC.BAT $@
--------

---MYVC.BAT---
@ECHO OFF
VCVARS32
VC %1 %2 %3 %4 %5
--------------

It is possible to setup a "startup script" for a given instance
of CMD using a shortcut, which can then be placed in the program
files menu or on the taskbar.  Also, the System control has a
place to setup environment variables.

> 
> They gave us WinXP at work, if the OS makes a difference.
> 
> Thanks!
> Peter
> _______________________________________________
> vox-tech mailing list
> vox-tech at lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech
> 


-- 
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------


More information about the vox-tech mailing list