【发布时间】:2019-05-10 08:05:03
【问题描述】:
我正在按照tutorial 在我的 Windows 电脑上设置 vs 代码。
我通过从其他文件夹调用 g++ 来检查路径是否正确。
但我在 vs 代码上不断收到此错误:
Cannot find "C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw64\bin\g++.exe".
尝试从helloworld.cpp 所在的文件夹中使用命令提示符运行g++ helloworld.cpp 不会给出错误或输出。
谁能告诉我我错过了什么?
编辑:
代码实际上已经编译好了。 它生成 a.exe 并且运行良好。 问题是我需要将它集成到 vs 代码中。 我猜它类似于this,但我不确定。
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw64/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
tasks.json已更正
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++.exe build active file",
"command": "g++",
"args": [
"-g",
"-o",
"helloworld",
"helloworld.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++.exe build active file",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.exe",
"helloworld",
"helloworld.cpp"
],
"options": {
"cwd": "C:/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw64/bin/"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
settings.json
{
"[cpp]": {},
"terminal.integrated.shell.windows": "C:\\cygwin64\\bin\\bash.exe"
}
launch.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": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw64/bin/g++.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
【问题讨论】:
标签: c++ visual-studio-code windows-10