cvisual-studiocommand-line64-bit

How to compile x64 code with Visual Studio in command line?


I want to compile a simple hello-world-style program using the Windows command line.

cl file_name.c

is easy enough. Now I want to do the same thing in 64 Bit. What should I do?


Solution

  • You need to use a version of the cl.exe compiler which emits x64 code. Which one depends a bit on your setup.

    Let's consider the case you're on a 64 bit machine. For this you'll need to use the compiler which lives at

    c:\Program Files (x86)\Microsoft visual Studio 10.0\VC\bin\amd64\cl.exe

    If you're on a 32 bit machine you'll need to use the cross compiler located at

    c:\Program Files\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\cl.exe