Using VC++ Command Line for the first time. Facing problem in setting proper paths for cl.exe and other header files:
///simple.cpp, saved at **D:\Program Files\VC**
#include <iostream>
int main()
{
std::cout << "This is a native C++ program." << std::endl;
return 0;
}
When typing on command:
cl /EHsc simple.cpp
returning error
D:\Program Files\VC> cl /EHsc simple.cpp
'cl' is not recognized as an internal or external command,
operable program or batch file.
Kindly note my Visual Studio is installed in D-drive.
As a work around I moved to bin folder where cl.exe is present:
D:\Program Files\VC\bin>cl /EHsc simple.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
simple.cpp
simple.cpp(1) : fatal error C1083: Cannot open include file: 'iostream': No such
file or directory
As you can see now it is unable to include “iostream”, which is present in include folder under D:\Program Files\VC\include
Please help me in setting the default paths properly.
Update:
Here are the content of the directory:
Directory of D:\Program Files\VC
06/15/2012 02:23 PM <DIR> .
06/15/2012 02:23 PM <DIR> ..
04/20/2012 12:24 PM <DIR> atlmfc
06/15/2012 02:35 PM <DIR> bin
04/20/2012 12:22 PM <DIR> crt
04/20/2012 12:24 PM <DIR> include
04/20/2012 12:24 PM <DIR> lib
02/23/2012 05:16 PM 1,525 Notepad.lnk
04/20/2012 12:23 PM <DIR> redist
06/15/2012 02:31 PM 146 simple.cpp
04/20/2012 12:22 PM <DIR> VCAddClass
04/20/2012 12:21 PM <DIR> VCContextItems
08/31/2009 02:46 AM 160 vcEmptyTestProject.vsz
04/20/2012 12:21 PM <DIR> VCNewItems
04/20/2012 12:22 PM <DIR> vcpackages
04/20/2012 12:21 PM <DIR> VCProjectDefaults
04/20/2012 12:25 PM <DIR> vcprojectitems
04/20/2012 12:25 PM <DIR> vcprojects
04/20/2012 12:22 PM <DIR> VCResourceTemplates
09/30/2009 08:23 PM 1,237 vcvarsall.bat
04/20/2012 12:25 PM <DIR> VCWizards
4 File(s) 3,068 bytes
17 Dir(s) 8,465,346,560 bytes free
For visual studio 2008 there is an environment variable: VS90COMNTOOLS that you can use. Probably something similar for VS2010.
so:
from the command line directly, or from a batch file:
“%VS90COMNTOOLS%vsvars32.bat”
(include the quotes!)
This should set up stuff appropriately.
You’ll need to replace %VS90COMNTOOLS% with the appropriate environment variable for 2010.