问题分析:需要配置正确的环境变量
解决方案:
1.先下载minGW工具MinGW(GNU工具集合)下载-MinGW官方免费下载-华军软件园d
2.利用xftp将windows下载好的MinGW工具转移到linux上
xftp的下载官网链接:家庭/学校免费 - NetSarang Website
3.找到.vscode文件夹中的以下三个文件:
修改c_cpp_properties.json文件中的环境路劲:
(1)c_cpp_properties.json配置
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/hfb/MinGW/include" //此处修改为linux下自己的MinGW/include路劲
],
"defines": [],
"compilerPath": "/home/hfb/MinGW/bin/gcc.exe", //此处修改为linux下自己的MinGW/bin路劲,如果用c编译就用gcc,用c++编译就用g++
"cStandard": "c11",
"cppStandard": "c++98",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
(2)settings.json配置
{
"files.associations": {
"stdio.h": "c",
"*.ipp": "c",
"*.tcc": "c",
"fstream": "c",
"unistd.h": "c"
},
"C_Cpp.errorSquiggles": "disabled"
}
(3)tasks.json配置
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc 生成活动文件",
"command": "gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}