我首先从https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/安装了Mingw,然后下载了所有软件包,并将C:\ MinGW \ bin设置为我的环境系统变量中的新路径。我打开命令提示符,然后键入“ g ++ --version”,这将给我输出“ g ++(MinGW.org GCC-8.2.0-5)8.2.0”。因此,我相信这意味着到目前为止,我已经遵循了正确的路径。
我在VSCode中尝试编译基本的hello world文件时出现问题。在终端中,我输入“ g ++ main.cpp”,但是这使我无法识别“ g ++”的内部或外部命令, 可操作的程序或批处理文件。”这与我的.json文件的设置方式有关吗?我提供了以下c_cpp_poperties,启动和任务代码。
谢谢。
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Compiler",
"type": "cppvsdbg",
"request": "launch",
"program": "C:/MinGW/bin",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
},
]}
task.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "C:/MinGW/bin/g++",
"args": [
"-g",
"-o",
"helloworld",
"helloworld.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]}
答案 0 :(得分:0)
替换
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
使用
"compilerPath": "C:\\MinGW\\bin\\g++.exe",