Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 904
bastibe Avatar asked Mar 30 '10 19:03

bastibe


People also ask

How do you launch Visual Studio tool x64 Cross Tools Command Prompt?

To access these command prompts on Windows, on the Start menu, open the folder for your version of Visual Studio, and then choose one of the x64 native or cross-tool developer command prompts.

What is x64 native tools command prompt?

x64 Native Tools Command Prompt - Sets the environment to use 64-bit, x64-native tools to build 64-bit, x64-native code. x86_x64 Cross Tools Command Prompt - Sets the environment to use 32-bit, x86-native tools to build 64-bit, x64-native code.

How do I run Visual Studio from the command line?

Start in Visual StudioOn the menu bar, select Tools > Command Line > Developer Command Prompt or Developer PowerShell.


2 Answers

Run cl from a Visual Studio x64 Command Prompt.

like image 20
Kyle Alons Avatar answered Sep 21 '22 19:09

Kyle Alons


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

like image 186
JaredPar Avatar answered Sep 20 '22 19:09

JaredPar