benkyou
benkyou

Reputation: 65

which command prompt of Visual Studio I shall use?

I am using VS2013 x86 version on my 64-bit computer. In this web vs command prompt introduces many types of prompts and I'm a little confused about it. Shall I use x64 native command prompt or x64 x86 Cross Tools Command Prompt?

Upvotes: 3

Views: 838

Answers (1)

Cody Gray
Cody Gray

Reputation: 244742

There are three versions of the compiler toolchain, and thus three different command prompts:

  • The "x86" tools run natively on 32-bit x86 systems and produce 32-bit x86 binaries.

    These are located in the /vc/bin directory, and the associated command prompt sets up the environment to use these tools.

  • The "x64" tools run natively on 64-bit x86 ("x64" in Microsoft vernacular) systems and produce 64-bit x86 binaries.

    These are located in the /vc/bin/amd64 directory, and the associated command prompt sets up the environment to use these tools.

  • The "x64-x86" cross-tools run on 32-bit x86 systems, but produce 64-bit x86 binaries.

    These are located in the /vc/bin/amd64_x86 directory, and the associated command prompt sets up the environment to use these tools.

Which one you use depends on what kind of binary you want to produce/manipulate.

If you want to generate 32-bit code, you need to use the x86 tools. These will run on either a 32-bit or 64-bit machine (the latter via the WOW64 subsystem, the same one responsible for running all 32-bit processes).

If you want to generate 64-bit code on a 32-bit system, you must use the x64-x86 cross-compiler. A cross-compiler is a compiler that generates code for a different platform than the one it is actually running on. A more obvious example would be a compiler that runs on x86 but produces ARM code. In this case, it's a 32-bit compiler that produces 64-bit code.

If you want to generate 64-bit code on a 64-bit system, you could instead choose to use the x64 native compiler. This gets you all the advantages of using a 64-bit process (larger address space, more architectural registers, etc.), and is probably what you would want to use. (But you could also use the x64-x86 cross-compiler on a 64-bit machine, thanks to the WOW64 subsystem mentioned above.)

Upvotes: 5

Related Questions