Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

装c++环境

gcc和g++都要
以ubuntu为例

sudo apt-get instal gcc
sudo apt-get instal g++ #没装会报错找不到比如iostream头文件

配置vscode

https://blog.csdn.net/jinking01/article/details/106186575

c/c++c++ IntelliSense插件

version1.70开始c++ IntelliSense没了,合并到c/c++

include path

关键是 配置c++ IntelliSense插件:这个插件会帮你解决所有include path的问题
ctrl+shift+P打开Command Palette,运行C/C++: Edit configurations... 生成c_cpp_properties.json

debug

配置

F5会生成launch.json,然后配置这个文件
有些时候不会,则在项目顶层目录的.vscode目录下新建launch.json
打开此文件在编辑界面右下角会出现add configuration...按钮,点击然后选择c/c++(gdb): Launch,然后填写launch.json内容即可
program指明调试的可执行文件路径,args指定传递给可执行文件program的参数,比如:

{
    // 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/yuanzhiqiu/external_multi_bfs/vertex_disjoint_path/build/main",
            "args": [
                "-n",
                "2",
                "-b",
                "128",
                "-m",
                "msbfs",
                "-g",
                "/home/yuanzhiqiu/test_dataset/disjoint_test.txt", //disjoint_test split_vertex_test
                "-p",
                "/home/yuanzhiqiu/vertex_pairs/disjoint_test.txt",
                "-o",
                ".",
            ],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

启动调试

如何调试:自己编译,然后F5唤起调试

评论