Bitcoin-Core

使用 Visual Studio Code 在 Linux/Ubuntu 上建構比特幣核心

  • November 3, 2021

是否有人開發 Bitcoin Core 使用 VSCode 在 Linux/Ubuntu 上進行編譯和調試?

如何配置 VSCode 來編譯 Bitcoin Core?

我找到了使用 VSCode 的解決方案,並將其用於編譯。

  1. 在你的機器上安裝vscode,包括 C/C++ 開發擴展
  2. .vscode在比特幣儲存庫文件夾的根目錄中創建一個名為的目錄
  3. 創建一個.vscode/c_cpp_properties.json文件。此文件包含 C/C++ 項目的配置,包括編譯器類型和源路徑。
  4. 創建一個.vscode/tasks.json文件。該文件包含建構和測試任務的配置,用於編譯程式碼並將錯誤解析到 IDE
  5. 點擊Ctrl+Shift+B執行建構任務

如果你想在 Windows 機器上開發,但在遠端 Linux 機器上建構和執行,這可以通過遠端開發擴展來完成。連接遠端伺服器後,在目錄下創建相關文件。

相關的json文件:

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}"
           },
       },
   ]
}

引用自:https://bitcoin.stackexchange.com/questions/110163