0

Does anyone developing Bitcoin Core use VSCode for compilation and debugging on Linux/Ubuntu?

How can one configure VSCode to compile Bitcoin Core?

3
  • 1
    I use VSCode as editor but do not compile C++ in it. Maybe few extensions help. Compiling in terminal using the instructions jonatack.github.io/articles/… works best.
    – user103136
    Commented Oct 12, 2021 at 16:49
  • @Prayank see answer below
    – user107511
    Commented Nov 3, 2021 at 14:27
  • Thanks for sharing. Upvoted. Will be helpful at some point.
    – user103136
    Commented Nov 3, 2021 at 18:38

1 Answer 1

3

I found a solution to work with VSCode, and use it for compilation.

  1. Install vscode on your machine, including the C/C++ development extension
  2. Create a directory named .vscode in the root of bitcoin repository folder
  3. Create a .vscode/c_cpp_properties.json file. This file contains the configuration for the C/C++ project, including compiler type and source path.
  4. Create a .vscode/tasks.json file. This file contains configuration for build and test tasks, which compiles the code and parses errors into the IDE
  5. Hit Ctrl+Shift+B to run the build task

If you want to develop on a Windows machine but build and run on a remote Linux machine, this can be done with the Remote Development extension. After connecting to the remote server, create the relevant files in the directory.

The relevant json files:

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${default}",
                "${workspaceFolder}/src"
            ],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64",
            "browse": {
                "path": [
                    "${workspaceFolder}/src"
                ],
                "limitSymbolsToIncludedHeaders": false,
                "databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db"
            }
        }
    ],
    "version": 4
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "command": "make -j 8",
            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": ["relative", "${workspaceFolder}/src"]
            },
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "Test",
            "type": "shell",
            "command": "make check",
            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": ["relative", "${workspaceFolder}/src"]
            },
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "group": {
                "kind": "test",
                "isDefault": true
            }
        },
        {
            "label": "Clean",
            "type": "shell",
            "command": "make clean",
            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": ["relative", "${workspaceFolder}/src"]
            },
            "options": {
                "cwd": "${workspaceFolder}"
            },
        },
    ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.