我刚刚安装了最新版本的visual studio 2017(15.3.4),使用C ++"桌面开发。包。我没有安装任何其他工具/软件包,因为我不能100%确定它们的用途(我只是想编写一个简单的C ++程序)。
我能够编译一个简单的" hello world"使用IDE的程序,但当我尝试使用" VS 2017开发命令提示符编译代码时#34;我一直收到错误fatal error C1083: Cannot open include file: whatever.h: No such file or directory
(注意:whatever.h
只是头文件名的占位符。)
例如,这是我的c ++代码,following a VS2017 walk through,
#include <iostream>
using namespace std;
void main()
{
cout << "Hello, world, from Visual C++!" << endl;
}
当我从命令行执行构建时
C:\Users\username\source\hello>cl /EHsc hello.cpp
我得到以下输出
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25508.2 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
hello.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.1
1.25503\include\crtdefs.h(10): fatal error C1083: Cannot open include file: 'cor
ecrt.h': No such file or directory
我在C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt
下找到了头文件,当我输入&#34;路径&#34;时,它不会出现在PATH
中。在命令提示符下。我尝试使用
PATH C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt;%PATH%
仍然没有运气。我试图以管理员身份打开命令提示符,没有运气。我试图包含路径
C:\Users\username\source\hello>cl /EHsc /I "C:\Program Files (x86)\Windows Kits\1
0\Include\10.0.15063.0\ucrt" hello.cpp
输出以下内容
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25508.2 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
hello.cpp
Microsoft (R) Incremental Linker Version 14.11.25508.2
Copyright (C) Microsoft Corporation. All rights reserved.
/out:hello.exe
hello.obj
LINK : fatal error LNK1104: cannot open file 'uuid.lib'
现在我有一个链接问题,但至少它似乎找到了正确的头文件。同样,除了默认安装,我什么都没做。
所有命令行构建尝试都会发生此错误。具体来说,我正在尝试构建最新的boost
库(1.65),因为我需要在我正在使用的程序中filesystem
。按照他们的#34;入门指南&#34;,我甚至无法通过第一步,执行&#34; bootstrap&#34;,因为它吐出了一堆C1083
错误抱怨关于丢失头文件。
无论如何,hello.cpp
的失败命令行构建(如上所述)表明我的默认安装VS2017出了问题。我使用的是64位Windows 7 Professional SP1。我在安装过程中没有遇到任何错误,我甚至卸载并重新安装程序以达到同样的问题。
关于如何使用命令行构建方法,我是否遗漏了什么?
答案 0 :(得分:0)
这不会修复VC安装过程中出现的任何问题或者bjam的错误(构建boost的正确方法),但最后一次LNK1104错误:
C:\ Users \ username \ source \ hello&gt; cl / EHsc / I&#34; C:\ Program Files(x86)\ Windows Kits \ 10 \ Include \ 10.0.15063.0 \ ucrt&#34; hello.cpp / link uuid.lib
对于放弃IDE的其他人,我建议只使用installing the build tools。