【vscode】——调试pybind11写的c++拓展

https://blog.csdn.net/u011622208/article/details/111302047,这篇博客写了如何用C++给python写拓展。然后又出现了一个新的问题。如何调试呢?

vscode配置
参考自:https://stackoverflow.com/questions/55098128/how-to-configure-vs-code-to-be-able-to-step-into-a-shared-library-so-that-is
修改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",
        }
    ]
}

结果
在这里插入图片描述

程序
csdn

没有积分的,留下邮箱


版权声明:本文为u011622208原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。