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.
To compile your program, enter cl hello. c at the developer command prompt. If you get an error such as "'cl' is not recognized as an internal or external command, operable program or batch file," error C1034, or error LNK1104, your developer command prompt is not set up correctly.
CL passes these options to the linker. You can specify any number of options, filenames, and library names, as long as the number of characters on the command line does not exceed 1024, the limit dictated by the operating system.
cl.exe is a tool that controls the Microsoft C++ (MSVC) C and C++ compilers and linker. cl.exe can be run only on operating systems that support Microsoft Visual Studio for Windows. You can start this tool only from a Visual Studio developer command prompt.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With