【发布时间】:2019-02-16 02:37:26
【问题描述】:
我得到了一些需要编译的 C++ 文件。我在 Windows 10 上使用带有 C/C++ 和 Code Runner 扩展的 Visual Studio Code。使用以下“包含”语句:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <unordered_map>
我收到以下错误:
unordered_map: No such file or directory
我对 C++ 很陌生,一直无法找到解决此问题的方法。我已经更新了我的 c_cpp_properties.json 文件中的“includePath”,如下所示。我也尝试过使用 Cygwin 和 Visual Studio Community 进行编译,但我得到了同样的错误。我知道 unordered_map .hpp 文件存在,但编译器似乎没有找到它。
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17134.0",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
如果相关,这就是我的 tasks.json 文件的样子:
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/t:build"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
我的 .json 文件配置正确吗?如果我遗漏了一些基本的东西,我深表歉意;我已经做了很多关于如何在 Windows 上编译 C++ 的搜索,但没有任何成功。提前感谢您的帮助。
编辑: 这是我正在尝试编译的完整文件。该可执行文件旨在由 python 脚本调用。
https://github.com/jorpjomp/sierra-hotel/blob/master/location_routing.cpp
【问题讨论】:
-
如果您创建了标准 c++ -> Win32 控制台项目,Visual Studio 社区版应该可以立即使用。我不知道为什么有人想在 Windows 上使用 VS 代码,但我可能很天真。你能显示你正在尝试编译的整个 .cpp 文件吗?
-
@ChristopherPisz 使用 Github 链接编辑了帖子。感谢您的帮助。
-
所以,如果我下载全新安装的 VS 社区,并创建一个新的控制台项目,然后将代码放入其中,则需要 node.h 和 routingEntry 的定义。只需将带有解决方案文件的整个项目和所有内容上传到 github,或者在此处放置 MCVE:stackoverflow.com/help/mcve
-
不要将整个项目/解决方案在线转储并在此处链接。 仅提供minimal reproducible example。
-
请添加工程文件和完整的编译器输出(需要看调用参数和编译器输出)
标签: c++ visual-studio-code include-path