本片文章主要是为了使用VSCode编译运行带QuickWin的老版本Fortran代码。
一、准备工作
安装VSCode和Compaq Visual Fortran6.6。
二、配置Fortran工程
用VSCode打开保存有Frotran代码的文件夹
建立.vscode文件夹,建立launch.json和task.json文件,分别复制下面的脚本:
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.0.1",
"configurations": [
{
"name": "Fortran Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x86",
"program": "${workspaceRoot}\\Debug\\ImpulseWaves.exe",
"miDebuggerPath": "D:\\Soft\\mingw64\\bin\\gdb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": true,
"preLaunchTask": "Build"
},
{
"name": "Intel Debug Attach",
"type": "cppvsdbg",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
task.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "C:\\Program Files\\Microsoft Visual Studio\\DF98\\Bin\\DFVARS.BAT" ,
"args": [
"&",
"DF.EXE",
"/check:bounds",
"/compile_only",
"/dbglibs",
"/debug:full",
"/libs:qwins",
"/nologo",
"/traceback",
"/warn:argument_checking",
"/warn:nofileopt",
"/module:'Debug\\'",
"/object:'Debug\\'",
"/pdbfile:'Debug\\DF60.PDB'",
".\\test1.f90",
".\\test2.f90",
".\\test3.f90"
"&",
"Link.exe",
"kernel32.lib",
"/nologo",
"/entry:WinMainCRTStartup",
"/subsystem:windows",
"/incremental:no",
"/pdb:Debug\\Test.pdb",
"/debug",
"/machine:I386",
"/nodefaultlib:dfconsol.lib",
"/out:Debug\\Test.exe",
"/pdbtype:sept",
".\\Debug\\test1.obj",
".\\Debug\\test2.obj",
".\\Debug\\test3.obj"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
}
三、编译和链接
做完以上两步后,点击Terminal-> Run Build Tasks即可执行task.json中的编译脚本。输出文件在当前文件夹下的Debug文件夹。
四、运行
点击Run-> Start Debugging,即可运行。
事实上,使用CVF(Compaq Visual Fortran)编译后,会产生pdb文件,但gdb.exe并不兼容这种格式调式符号,所以是无法调试的,运行Start Debugging和Run Without Debugging效果一样。
有哪位客官知道怎么在VScode中使用Windbg,还望不吝赐教。