【VScode】C语言环境配置填坑 | 报错:no iconv implementation | unrecognized command line option “-std=c++11

网上同志们的流程

1.安装MinGw
2.配置环境变量
【VScode】C语言环境配置填坑 | 报错:no iconv implementation | unrecognized command line option “-std=c++11_第1张图片
3.csvode中下载cpp插件
【VScode】C语言环境配置填坑 | 报错:no iconv implementation | unrecognized command line option “-std=c++11_第2张图片4.按f5配置launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "(gdb) Launch",
      "preLaunchTask": "Build",
      "type": "cppdbg",
      "request": "launch",
      "targetArchitecture": "x86_64",
      "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
      "miDebuggerPath": "c:\\MinGW\\bin\\gdb.exe",(同志!这里改你的路径,不能用我的路径)
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": true,
      "MIMode": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    }
  ]
}

5.配置tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared"
            },
            "windows": {
                "command": "g++",
                "args": [
                    "-ggdb",
                    "\"${file}\"",
                    "--std=c++11",
                    "-o",
                    "\"${fileDirname}\\${fileBasenameNoExtension}.exe\"",
                ]
            }
        }
    ]
}

以上步骤是完全正确的,我强调一遍!

但是vscode它就是爆粗了,啊不,报错了:
1.unrecognized command line option “-std=c++11
2.no iconv implementation,cannot convert from UTF-8 to GBK
好好好,我们来一一解决

报错1:unrecognized command line option “-std=c++11

发现task.json
【VScode】C语言环境配置填坑 | 报错:no iconv implementation | unrecognized command line option “-std=c++11_第3张图片看看看看,我要用C语言环境,这里必须要改成

"windows": {
                "command": "gcc",
                "args": [
                    "-ggdb",
                    "\"${file}\"",
                    "--std=c99",
                    "-o",
                    "\"${fileDirname}\\${fileBasenameNoExtension}.exe\"",
                ]
            }

哎,c++11不行,咱用c99嘛

报错2:no iconv implementation,cannot convert from UTF-8 to GBK

还是刚刚那段,加两句(两行/中间的两句)

"windows": {
                "command": "gcc",
                "args": [
                    "-ggdb",
                    "\"${file}\"",
                    "--std=c99",
                    "-o",
                    "\"${fileDirname}\\${fileBasenameNoExtension}.exe\"",
                    
                    "-finput-charset=UTF-8",//输入编译器文本编码 默认为UTF-8
                    "-fexec-charset=UTF-8"//编译器输出文本编码 自行选择
                    
                ]
            }

这样你编译器没说的了,乖乖执行我的程序吧!
【VScode】C语言环境配置填坑 | 报错:no iconv implementation | unrecognized command line option “-std=c++11_第4张图片

(一闪而过的话,别忘了加getchar();啊!)

你可能感兴趣的:(【VScode】C语言环境配置填坑 | 报错:no iconv implementation | unrecognized command line option “-std=c++11)