首次使用VC ++命令行。在设置cl.exe和其他头文件的正确路径时遇到问题:
///simple.cpp, saved at **D:\Program Files\VC**
#include <iostream>
int main()
{
std::cout << "This is a native C++ program." << std::endl;
return 0;
}
在命令上输入时:
cl /EHsc simple.cpp
返回错误
D:\Program Files\VC> cl /EHsc simple.cpp
'cl' is not recognized as an internal or external command,
operable program or batch file.
请注意我的Visual Studio安装在D-drive中。
作为解决方法,我移动到cl.exe存在的bin文件夹:
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
正如您现在所看到的,它无法包含“iostream”,它存在于D:\ Program Files \ VC \ include
下的include文件夹中请帮我正确设置默认路径。
更新:
以下是目录的内容:
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
答案 0 :(得分:0)
打开Visual Studio命令提示符,它是一个命令提示符,可以在路径中找到相应的目录。
答案 1 :(得分:0)
对于visual studio 2008,有一个环境变量:您可以使用VS90COMNTOOLS。 VS2010可能类似。
所以: 直接从命令行,或从批处理文件: “%VS90COMNTOOLS%vsvars32.bat”
(包括引号!)
这应该适当地设置东西。
您需要将%VS90COMNTOOLS%替换为2010年的相应环境变量。
答案 2 :(得分:0)