title: Force SCons to use 32-bit MSVC compiler on 64-bit Windows
body: <p>I am trying use <code>cl</code> from Visual Studio 2010 to build the 32-bit version of <a href="https://github.com/mixxxdj/mixxx" rel="nofollow noreferrer">Mixxx</a>. Mixxx uses SCons to build. My computer is Windows 7 64-bit with too many versions of Visual Studio installed.</p>
  
  <p>Following <a href="http://mixxx.org/wiki/doku.php/compiling_on_windows" rel="nofollow noreferrer">these instructions</a>, I have tried all sorts of combinations and variations of <code>setenv</code> and <code>vsvars</code> but no matter what I do, I end up on the command line in this situation:</p>
  
  <pre><code>&gt; cl
  Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  usage: cl [ option... ] filename... [ /link linkoption... ]
  </code></pre>
  
  <p>OK, so <code>cl</code> is pointing to "version 16, x86" - great.</p>
  
  <pre><code>&gt; scons toolchain=msvs force32=1 winlib=%cd%\winlib\x86 sqlitedll=0 staticlibs=1 asmlib=0
  
  [... bunch of output truncated, until we start using the compiler ...]
  
  cl /Fores\qrc_mixxx.obj /c res\qrc_mixxx.cc /TP /Zc:wchar_t- /GL /MP /fp:fast /G
  [truncated]
  Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  </code></pre>
  
  <p>(Note - I hacked SCons to remove the <code>/nologo</code>) What? How does <code>cl</code> now mean "version 18, x64"? Did it change my environment? Let's find out:</p>
  
  <pre><code>Terminate batch job (Y/N)? y
  
  &gt;cl
  Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  usage: cl [ option... ] filename... [ /link linkoption... ]
  </code></pre>
  
  <p>So <code>cl</code> still means "version 16, x86" to the terminal. But SCons always uses "latest version, x64".</p>
  
  <p><strong>(Based on my understanding of the Windows shell, this should not even be possible. I killed the script, so it didn't do any cleanup. How can the meaning of <code>cl</code> change like that?)</strong></p>
  
  <p>I've found a couple hints:</p>
  
  <ul>
  <li><a href="http://scons.1086193.n5.nabble.com/Using-32-bit-MSVC-compiler-on-64-bit-Windows-td28062.html" rel="nofollow noreferrer">http://scons.1086193.n5.nabble.com/Using-32-bit-MSVC-compiler-on-64-bit-Windows-td28062.html</a></li>
  <li><a href="http://www.scons.org/wiki/MsvsMultipleVersions" rel="nofollow noreferrer">http://www.scons.org/wiki/MsvsMultipleVersions</a></li>
  <li><a href="https://stackoverflow.com/questions/3079344/forcing-scons-to-use-older-compiler">Forcing scons to use older compiler?</a></li>
  </ul>
  
  <p>Based on this, I've added</p>
  
  <pre><code>Environment(MSVC_VERSION = '10.0')
  Environment(TARGET_ARCH = 'x86')
  print 'hello world'
  </code></pre>
  
  <p>to the SConstruct. I don't know SCons, and the build scripts are non-trivial, so it's likely that I'm doing this wrong. Regardless, SCons still always uses "newest version, x64".</p>