c++ - 无法在 Visual Studio Code 中构建 c++
问题描述
看起来是这样的,除了我跟着它,我仍然无法让它在 VS Code 中工作。这是我使用的目录:
C:\Users\EKI\Desktop\projects_cpp
按照说明,我将 .json 文件放在 \project_cpp.vscode 中,将 .cpp 文件放在 \projects_cpp\helloworld 中。
我的 .cpp 文件:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
}
.json 文件如下:
启动.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
设置.json
{
"files.associations": {
"ostream": "cpp"
}
}
任务.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"$${workspaceFolder}\\${fileBasenameNoExtension}",
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
我尝试关闭受控文件夹访问,但仍然无法正常工作。
这是错误消息
执行任务:g++ -gc:\Users\EKI\Desktop\projects_cpp\helloworld\helloworld.cpp -o $C:\Users\EKI\Desktop\projects_cpp\helloworld <
g++.exe:错误:c:UsersEKIDesktopprojects_cpphelloworldhelloworld.cpp:没有这样的文件或目录 g++.exe:致命错误:没有输入文件编译终止。终端进程以退出代码终止:1
解决方案
推荐阅读
- flutter - 警告:您当前运行的“颤振”工具不是当前目录中的工具
- javascript - 如何比较对象
- html - 如何使用 react-json-to-table 呈现可点击的 url?
- kotlin - Micronaut @Retryable 注释中的 KClass 无法编译为更正类对象
- sql - 为报告目的减少查询运行时间
- asp.net-core - 如何从 .NET Core WebAPI 使用/运行 .NET Framework dll/app
- python - 我如何从 python 中的此类错误中知道
- javascript - Zeroclipboard-rails 不工作但没有错误
- python - Python 2 imp - ValueError:尝试在非包中进行相对导入
- electron - 增加电子渲染器进程的内存限制?