欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

[vscode] - 调试 pybind11 编写的 c++ 扩展程序

最编程 2024-03-12 15:38:05
...

 这篇博客写了如何用C++给python写拓展。然后又出现了一个新的问题。如何调试呢?

vscode配置
 
修改vscode的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.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/data/miniconda3/envs/test/bin/python",        // 1. 修改python的路径
            "args": [
                "test.py"       // 2. 修改自己测试启动的python脚本
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
        }
    ]
}

结果
【vscode】——调试pybind11写的c++拓展_python脚本

程序
 

没有积分的,留下邮箱