How to include CERN root directory in c_cpp_properties.json of Visual Studio Code running in Ubuntu?

I have recently installed Visual Studio on Ubuntu to help me with writing Geant4 code, and it’s awesome. However try as I may I can not find a way to include the CERN Root directories into c_cpp_properties.json so that I can develop Root scripts in Visual Studio in order that I can process my simulated data.

CERN Root is working on my computer using my Sublime text editor. I have tried to locate the CERN Root header files but I can’t seem to find them as easily as I did for Geant4, and I don’t understand why?

Below is my c_cpp_properties.json script. For what it’s worth, I would appreciated immensely if someone could help me understand how to include CERN Root directories into c_cpp_properties.json so that I can write Root scripts in Visual Studio.

Thank you for your time

Peter

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${G4INCLUDES}/**",
                "/home/compton/Documents/geant4.10.05.p01/geant4-install/share/Geant4-10.5.1/examples/extended/polarisation/Pol01/include",
                "/home/compton/Documents/geant4.10.05.p01/geant4-install/share/Geant4-10.5.1/examples/extended/polarisation/Pol01/src",
                "/home/compton/Documents/geant4.10.05.p01/source/run/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu18",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

Hi Pietro,
and welcome to the ROOT forum!

When you say Visual Studio you mean Visual Studio Code I guess, since you are on Ubuntu?

I am not familiar with the json config files in VS Code, but for example root-config --cflags prints compilation flags that also include the location of ROOT’s header files. In most cases it will be ${ROOTSYS}/include, but it depends on the installation method of course.

I hope this helps!
Enrico

1 Like

Dear Enrico,
Thank you for your warm welcome.
Yes: I do mean Visual studio code! And thank you for your suggestion to use root-config --cflags. That’s exactly what I needed to find out in which directory my ROOT files are in. For me, I include the following into my c_cpp_properties.json and it works just fine

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${ROOTSYS}/include",
                "${G4INCLUDES}/**",
                "/home/compton/Downloads/build-root/include",
                "/home/compton/Documents/geant4.10.05.p01/examples/Projects/1-POLARIZATION/Pol01a/include",
                "/home/compton/Documents/geant4.10.05.p01/examples/Projects/1-POLARIZATION/Pol01a/src",
                "/home/compton/Documents/geant4.10.05.p01/source/run/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu18",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

Thanks you very much for your help.
Best
Pietro

1 Like

Alright, glad it works! I updated the title to avoid confusion between Visual Studio and VS code :+1:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.