How do I load the 64-bit Visual Studio Tools Command Prompt?

18,785

Solution 1

Install the x64 Components

The problem is an incomplete installation of Visual Studio. I only installed the C# components. I needed to install, at least, the Visual C++ x64 Compilers and Tools.

Adding Components to an Existing Installation

I had problems adding those components to an existing installation. VS2010, especially with SP1 installed, has a ton of bugs around modifying the installation. I encountered some kind of path not found error

  1. I uninstalled SP1 first. I needed the VS2010 installation media on hand (unpack to a directory, insert the real disc, or mount to a virtual drive).
  2. Then I added the VC++ components to the VS installation
  3. Then I was able to reinstall SP1.

Solution 2

When running in the batch processor, %~dp0 expands to the path where the .bat file is executing. So in the default install for VS2010, that resolves to c:\program files\microsoft visual studio 10.0\vc\bin\amd64\vcvars64.bat. Which is indeed missing, that's a bug they don't seem to be interesting in fixing.

Use "x86_amd64" instead. You'll get the cross compiler, the same one that's used by the IDE.

Share:
18,785
Anthony Mastrean
Author by

Anthony Mastrean

Updated on June 04, 2022

Comments

  • Anthony Mastrean
    Anthony Mastrean almost 2 years

    My development machine is running Windows 7 Ultimate x64. I installed Visual Studio 2010 Ultimate. When I open the Visual Studio Command Prompt (2010), I get the message

    Setting environment for using Microsoft Visual Studio 2010 x86 tools.

    I have also setup the PowerShell Community Extensions in my Windows PowerShell user profile. And I use the Invoke-BatchFile cmdlet to install the Visual Studio Tools into all my PowerShell sessions

    $vcargs = ?: {$Pscx:Is64BitProcess} {'amd64'} {'x86'}
    $vcvars = "${env:VS100COMNTOOLS}..\..\VC\vcvarsall.bat"
    Invoke-BatchFile $vcvars $vcargs
    

    My vcargs resolves to amd64. I looked in the vcvarsall.bat file for the location of the x64 batch file and got ~dp0bin\amd64\vcvars64.bat. That directory (and file) does not exist.

    How do I get the vcvars64.bat file installed properly?

  • user1703401
    user1703401 about 13 years
    Don't uninstall anything, this is a known bug with a simple workaround.
  • Anthony Mastrean
    Anthony Mastrean about 13 years
    I looked at the path for that parameter, %~dp0bin\x86_amd64\vcvarsx86_amd64.bat. That file also doesn't exist on my machine.
  • user1703401
    user1703401 about 13 years
    Did you get the explanation of what %~dp0 means? This .bat file does exist (vc\bin\x86_amd64 subdirectory), unless you intentionally skipped installing the 64-bit compilers. Test by typing "vcvarsall x86_amd64" at the command line prompt.
  • Anthony Mastrean
    Anthony Mastrean about 13 years
    I know what ~dp0 is. I'm running vcvarsall.bat which you provide an architecture switch (I'm passing in amd64). That bat file points you to the bat file for your architecture. None of the x64 specific bat files exist on my machine.
  • user1703401
    user1703401 about 13 years
    You have the vc\bin\x86_amd64 directory but it doesn't contain the vcvarsx86_amd64.bat file? Dated 11/15/2009? Rough, start by running Repair.
  • user1703401
    user1703401 about 13 years
    (I'm passing in amd64). That was the point of my answer. Don't. Pass in x86_amd64.
  • Anthony Mastrean
    Anthony Mastrean about 13 years
    Haha, yeah, did that already. I'm really certain that it's because I didn't install the VC++ components at first. But now I'm paying the uninstall/re-install costs (time time time). These installation bugs are killing me.
  • Anthony Mastrean
    Anthony Mastrean about 13 years
    The only param that resolves to a good bat file is x86. But I'm on an x64 machine. I should be able to use the x64 tools. I want to use the x64 tools. I'm going to fight this fight until I win!
  • Anthony Mastrean
    Anthony Mastrean about 13 years
  • mcmillab
    mcmillab over 11 years
    the only bat file I have is vcvars32.bat - but cl.exe exists in the relevant subdirs. How do I get vcvars64.bat?
  • Anthony Mastrean
    Anthony Mastrean over 11 years
    Man, downvote without a comment sucks. Is it about the disagreement with Hans? I don't know how to state my case any differently. I did not have the components Hans was referring to without installing the VC++ x64 tools.