【发布时间】:2021-11-21 10:25:46
【问题描述】:
我正在开发一个需要调试 C++ DLL/Lib 的项目。我有 DLL/PDB/H/Source 文件,我需要一个“客户端”来调用 DLL,这样我就可以调试一些功能。
到目前为止,我在 Visual Studio 中有一个“DLL 客户端”的解决方案。为了让它工作,我必须添加我的“附加包含目录”(.h 文件),“链接器”上的 dll 路径,并在“构建事件”中对 dll/pdb 进行 xcopy。 这是可行的,但我不太喜欢 Visual Studio 界面,想尝试使用 VSCode 进行编码/调试。
到目前为止,我的客户非常简单:
#include <iostream>
#include "mydll.h"
int main()
{
char version[20];
GetVersion(version);
std::cout << "Version: " << version << '\n';
}
我的 DLL 是用 makefile 制作的。我在如何在 VSCode 上设置我的 launch.json(或设置什么)以添加包含目录和 pdb 信息时遇到问题,所以当我运行我的客户端时,dll/pdb 链接到客户端。
launch.json 是 vscode 的默认值,只是改了个名字
{"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
}
]
}
]
}
有什么帮助吗?谢谢
【问题讨论】:
-
您可能需要显示您的
launch.json是否也在使用 Makefile 工具扩展:https://devblogs.microsoft.com/cppblog/now-announcing-makefile-support-in-visual-studio-code/ -
@drescherjm 会检查一下
标签: c++ visual-studio debugging visual-studio-code dll