Make writing a habit together! This is the 12th day of my participation in the “Gold Digging Day New Plan · April More text Challenge”. Click here for more details.

I have always preferred Visual Studio as the IDE of choice for C++ development, from version 08 to the current version 19, for a long time. Are there other ides to choose from? Of course there are! This article takes you through the VS Code configuration to compile, run, and debug Geant4 and Root.

Development Environment Configuration

System environment

Virtualization platform: VMware WorkStation 16 Pro

Operating system: Ubuntu 16.04 LTS

The installation

Go to VS Code’s official website or Chinese website and choose the version suitable for the system to download. Here I chose the Linux version.

After downloading, it is a brainless installation. The operation is fierce like a tiger. After installation, enter the page as shown in the picture below for the first time and choose your favorite theme and desired functions.

Add C++ related plug-ins

Search the extension options to add C++ related plug-ins, including the Cmake compiler.

Add Geant4 and Root external dependencies

Before adding dependencies, create a new directory (I’ll call it Root_First) as a workspace and open it with VS Code.

Then press Ctrl+Shift+P to show All Command and select C/C++ Edit Configuration

A hidden file is automatically generatedc_cpp_properties.jsonAnd put them in.vscodeDirectory.

Next we introduce Geant4 and Root dependencies by modifying the c_cpp_properties.json file.

{
    "configurations": [{"name": "Linux"."browse": {"path": ["${workspaceFolder}/src"."${workspaceFolder}/include"."/home/ll/root/include"."/ home/ll/geant4.10.04 / include/Geant4." "]."limitSymbolsToIncludedHeaders":true
            },
            "includePath": ["${workspaceFolder}/src"."${workspaceFolder}/include"."/home/ll/root/include"."/ home/ll/geant4.10.04 / include/Geant4." "]."defines": []."compilerPath": "/usr/bin/gcc"."cStandard": "c11"."cppStandard": "c++17"."intelliSenseMode": "linux-gcc-x64"}]."version": 4
}
Copy the code

A quick explanation:

  • The ${workspaceFolder} / SRC links the SRC
  • ${workspaceFolder} / include links to include
  • / home/ll/root/include links to the root
  • / home/ll/geant4.10.04 / include/Geant4 Geant4 link

At this point, the external link library has been configured so that the dependencies are not red flagged and can be used to remind methods of options and syntax checks when they are called by Pointers to class objects.

Friendly reminder: remember to copy this configuration to the.vscode directory for each working directory (if you don’t have a.vscode directory, create a new one).


To be continued! Don’t read enough, subscribe to follow me, continue to update excellent articles!