通过cygwin配置环境
以前这么弄还行,现在这么搞c没问题,fortran能编译不能调试,老说有个库调不了,可能装的环境少了,建议看最下面simply fortran办法
一、通过cygwin安装相关编译器
安装devel下的:gcc-core, gcc-fortran, gcc-g++, gdb,保证版本一致
cygwin安装完成后,将bin文件夹添加到系统环境变量PATH
二、Vscode插件安装
依次安装c/c++、fortran、Fortran Breakpoint Support插件
三、配置C++
调试选GDB,要求配置launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true, //修改此项,让其弹出终端
"MIMode": "gdb",
"miDebuggerPath": "C:\\software\\cygwin\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "task g++" //修改此项
}
]
}
task.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "task g++",
"command": "C:\\software\\cygwin\\bin\\g++.exe", //修改此项
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\software\\cygwin\\bin" //修改此项
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
调试报错,不能打开源文件,在报错出点小灯泡-编译器路径
路径如
C:\software\cygwin\bin\g++.exe
并按照提示修改IntelliSense 模式为linux-gcc-x64
四、配置gfortran
调试选GDB,要求配置launch.json
{
"version": "0.0.1",
"configurations": [
{
"name": "Fortran Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x86",
"program": "${workspaceRoot}\\${fileBasenameNoExtension}.exe",
"miDebuggerPath": "gdb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": true,
"preLaunchTask": "gfortran"
},
{
"name": "Intel Debug Attach",
"type": "cppvsdbg",
"request": "attach",
"processId": "${command:pickProcess}"
}
] }
在.vscode内新建tasks.json
内容如下
{
"version": "2.0.0",
"command": "gfortran",
"args": [
"-g",
"${file}",
"-o",
"${workspaceRoot}\\${fileBasenameNoExtension}.exe"
]
}
F5启动调试即可
通过simply fortran配置环境
simply fortran安装之后会自动配置好gcc、gfortran、gdb等环境,虽然软件要钱,但环境不要钱,白嫖一波,
配置文件同cygwin配置情况,
注意修改miDebuggerPath的路径就行了