【发布时间】:2021-02-09 09:34:05
【问题描述】:
我的 Visual Studio 总是无法编译任何 C++ 程序。我没有篡改或修改编译器。
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
给出输出:
1>Program
1>c1xx : fatal error C1083: Cannot open source file: 'C:\Program': No such file or directory
1>Files
1>c1xx : fatal error C1083: Cannot open source file: 'Files': No such file or directory
1>Microsoft
1>c1xx : fatal error C1083: Cannot open source file: '(x86)\Microsoft': No such file or directory
1>Visual
1>c1xx : fatal error C1083: Cannot open source file: 'Visual': No such file or directory
1>x64
1>c1xx : fatal error C1083: Cannot open source file: 'Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64': No such file or directory
1>test.cpp
1>Generating Code...
1>Done building project "test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我认为其中一条路径缺少双引号,但我不知道在哪里解决此问题。
【问题讨论】:
-
如何调用编译器?你能显示用于调用编译器的命令吗?
-
你能把你
.vcxproj的内容贴出来吗?由于编译器会输出这些消息,我敢打赌<ClCompile>汤而不是编译器路径问题。 -
允许文件名中包含空格的人需要一个强有力的交谈。
-
以这种方式导致 MSVC 失败需要付出很多努力。看起来您一直在弄乱 PATH 和/或环境变量,或者您的 CMake 项目已损坏/无效。最好的做法是撤消对环境的所有更改,重新启动并开始一个新的 MSVC 项目。此外,您可能还想升级到 MSVC 2019。
-
看起来某处引号字符丢失(或已被删除),因为某些路径被空格干扰。这很不寻常,因为该路径指向标准库二进制文件。
标签: c++ visual-studio visual-c++