Im working on a project where i need to debug a C DLL/Lib. I have the DLL/PDB/H/Source files and i need a "Client" to invoque the DLL so i can debug some functions.
So far i have in Visual Studio a solution for a "DLL Client". To have it working i had to add my "Aditional Include Directories" (the .h file), the dll path on "Linker" and do a xcopy of the dll/pdb in "Build Events". This is working but i dont like the visual studio interface very much and want to try to code/debug with VSCode.
My client is very simple so far:
#include <iostream>
#include "mydll.h"
int main()
{
char version[20];
GetVersion(version);
std::cout << "Version: " << version << '\n';
}
My DLL is made with a makefile. Im having trouble on how to set up my launch.json (or what to setup) on VSCode to add the include directories and the pdb info so when i run my client the dll/pdb is linked to the client.
The launch.json is the default of vscode only with a name change
{"configurations": [
{
"name": "(gdb) DLL Client",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/dllclient.out",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Any help? Thanks
CodePudding user response:
So, i dont know if its the best solution but is the one i could find. Probably there is some way to improove this with the C extension of vscode.
launch.json (for debug)
{"configurations": [
{
"name": "(gdb) VCVarsall 32",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}\\main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"targetArchitecture": "x86",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"preLaunchTask": "C : vcvarsall Main 32",
},
]}
tasks.json (to build main and link the library)
{
"tasks": [
{
"type": "process",
"label": "C : vcvarsall Main 32",
"command": "cmd",
"options": {"cwd": "${workspaceFolder}"},
"args": ["/C vcvarsall x86 && cl /Od /Zi /EHsc /Fd:vc140.pdb /Fo:main.obj ./main.cpp /I ${workspaceFolder}\\dev /link ${workspaceFolder}\\libs\\mylibrary.lib /OUT:main.exe /PDB:vc140.pdb"
],
"group": {
"kind": "build",
"isDefault": true
},
}
],
"version": "2.0.0"
}