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

网上同志们的流程

1.安装MinGw
2.配置环境变量
在这里插入图片描述
3.csvode中下载cpp插件
在这里插入图片描述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
在这里插入图片描述看看看看,我要用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"//编译器输出文本编码 自行选择
                    
                ]
            }

这样你编译器没说的了,乖乖执行我的程序吧!
在这里插入图片描述

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

  • 13
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值