C# · 12月 20, 2021

win7x32使用vscode调试c语言调试sqlite3范例配置

程序范例:

#include

#include

#include “sqlite3.h”

int main(int argc,char* argv[])

{

sqlite3 *db;

char *zErrMsg = 0;

int rc;

rc = sqlite3_open(“test.db”,&db);

if( rc ){

fprintf(stderr,”Can’t open database: %sn”,sqlite3_errmsg(db));

exit(0);

}else{

fprintf(stderr,”Opened database successfullyn”);

}

sqlite3_close(db);

getchar();

return(0);

}

c_cpp.json配置

{

“configurations”: [

{

“name”: “Win32”,

“includePath”: [

“${workspaceFolder}/**”,

“c:/mingw”,

“C:\mingw\bin”,

“C:\mingw\include”,

“C:\mingw\lib”,

“c:/sqlite3”

],

“defines”: [

“_DEBUG”,

“UNICODE”,

“_UNICODE”

],

“intelliSenseMode”: “msvc-x64”

}

],

“version”: 4

}

launch.json配置

{

// 使用 IntelliSense 了解相关属性。

// 悬停以查看现有属性的描述。

// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387

“version”: “0.2.0”,

“configurations”: [

{

“name”: “(gdb) Launch”,

“type”: “cppdbg”,

“request”: “launch”,

“program”: “${workspaceFolder}/hello.exe”,

“args”: [],

“stopAtEntry”: false,

“cwd”: “${workspaceFolder}”,

“environment”: [],

“externalConsole”: true,

“MIMode”: “gdb”,

“miDebuggerPath”: “C:/mingw/bin/gdb.exe”,

“preLaunchTask”:”build”,

“setupCommands”: [

{

“description”: “Enable pretty-printing for gdb”,

“text”: “-enable-pretty-printing”,

“ignoreFailures”: true

}

]

}

]

}

tasks.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:\mingw\bin\gcc.exe”,

“args”: [

“-I”,”c:/sqlite3/”,”-L”,”-lsqlite3″,”-g”,”hello.c”,”-o”,”hello”

],

“group”: {

“kind”:”build”,

“isDefault”: true

}

}

]

}

路径用或者/,否则报错。

系统path必须添加sqlite3的路径。

gcc参数放在args数组里面,不用每次手动输入。