Am trying to use the Visual Studio Express 2010 C++ compiler without using the IDE. I found cl.exe in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin. However am having a few difficulties. Firstly it gave me a warning pop up when i type cl saying 'Program cannot start because mspdb100.dll is missing from your computer.'
So i add C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE to the system path and then try again, but this time:
fatal error C1510: Cannot load language resource clui.dll.
Any idea how to solve this so i can compile? Also how would i set up the path so i can just type 'cl main.cpp' etc, from within a solution folder that does not contain cl.exe. At the moment i have to be inside bin folder. Thanks.
Try starting the Visual Studio Command Prompt from
Start->
All Programs ->
Microsoft Visual Studio 2010 ->
Visual Studio Tools ->
Visual Studio Command Prompt 2010
Alternatively, you can set up the environment by running this in a command prompt:
"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
(note: this will leave your environment set up after running.)
(note2: change x86
as desired. options are x86
, ia64
, amd64
, x86_amd64
, x86_ia64
)
From there you can run cl.exe
. If you want this to be automatically done and undone whenever you run cl
, create a batch file with this content:
@echo off
%comspec% /c ""c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 && cl.exe %*"
(the /c
tells the command prompt to end the session after running this command, so your environment returns to normal.)
From there, name it cl.bat
. Put this in a folder somewhere, and add the path to that folder to your PATH
environment variable, making sure it comes before the path to cl.exe
, so that this cl.bat
is executed whenever you type cl
instead of cl.exe
I recommend you just put cl.bat
in your system32/
folder, it should come before cl.exe
's path on a default installation.
Alternatively, you can add it in any order and always type cl.bat
, or name it something else so there's no confusion.
This is a quite simple and strait forward task. Firstly add the compiler path to system path.:C:\Program Files\Microsoft Visual Studio 10.0\VC\bin; Next, open command prompt and change directory to your source folder; Then execute the vcvars32.bat file to setup the environment for using vc++ on x86; After this, you can now type cl to compile your program
Just use vcvarsall.bat
as jsvk suggested:
"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
After that, use devenv.exe
to build your stuff if you keep yourself safe from a lot of head-aches:
devenv solutionfile.sln /build [ solutionconfig ] [ /project projectnameorfile [ /projectconfig name ] ]
There are a lot of other command line switches which you can check with devenv /?
.
I have multiple versions of VS installed; I create a little .BAT file for each version, placed somewhere in the path, that calls the relevant "vcvarsall.bat". e.g. "vc9.bat" calls vcvarsall.bat for VS2008, while "vc10.bat" calls vcvarsall.bat for VS2010. I can open a normal command window as usual, type "vc9", and presto, that command window is ready to compile etc using VS2008.
That errors occurs when the linker runs out of memory.
You can use the x64 tool architecture Visual studio tools.
msbuild command line:
msbuild myproject.vcxproj /p:PreferredToolArchitecture=x64
Or, better yet, add it to the project's settings in the .vcxproj.
To specify the 64-bit version of the compiler and tools, add the following property group element to the Myproject.vcxproj project file after the Microsoft.Cpp.default.props element:
<PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
These options will make Visual studio use the tools under the amd64 architecture folders (according to the target architecture):
VC\bin\amd64
VC\bin\amd64_x86
VC\bin\amd64_arm
https://msdn.microsoft.com/en-us/library/dd293607.aspx