VS Code configuration using Geant4 and Root (2)

Get into the habit of writing together! This is the 12th day of my participation in the "Nuggets Daily New Plan · April Update Challenge", click to view the details of the event .

For a long time, I have always preferred Visual Studio as the IDE for C++ development. From version 08 to version 19, which is currently commonly used, it has not changed for a long time. Are there other IDEs to choose from, of course there are! This article walks 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

image.png

OS: Ubuntu 16.04 LTS

image.png

Install

Go to the VS Code official website or Chinese website , select the version that suits the system to download, here I choose the Linux version.

image.pngAfter the download is complete, it is a brainless installation. The operation is as fierce as a tiger. After the installation is completed, the first time you enter the page as shown in the figure below, select your favorite theme and desired function.

image.png

Add C++ related plugins

Search and add C++-related plugins on the extension options, including the Cmake compilation tool.

image.png

Add Geant4 and Root external dependencies

Before adding dependencies, create a new directory (I named it Root_First arbitrarily) as a workspace and open this directory through VS Code.

Then by Ctrl+Shift+Pkey combination show All Command, then selectC/C++ edit configuration

Comment 2022-04-09 112834.pngAt this time, a hidden file will be automatically generated c_cpp_properties.jsonand placed in the .vscodedirectory.

image.png

c_cpp_properties.jsonNext, we introduce the dependencies of Geant4 and Root by modifying the files.

{
    "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
}
复制代码

Briefly explain:

  • ${workspaceFolder}/src 链接src
  • ${workspaceFolder}/include 链接include
  • /home/ll/root/include 链接root
  • /home/ll/geant4.10.04/include/Geant4 link geant4

At this point, the configuration of the external link library has been completed, and the related dependencies will not be marked in red to report errors, and you can also use the class object pointer to call methods to remind some optional options and syntax checking and other functions.

image.png

Friendly reminder : Remember to copy this configuration to the .vscode directory for each working directory in the future to take effect (if there is no .vscode directory, you might as well create a new one).


To be continued!
I haven't seen enough, subscribe and follow me, and continue to update excellent and good articles!

Guess you like

Origin juejin.im/post/7085531813518508045
Recommended