Skip to content
DavidHerreros edited this page May 28, 2020 · 7 revisions

Visual Studio Code

Visual Studio Code is a popular code editor developed by Microsoft that integrates many useful functionalities (like debugging or code completion) to simplify coding. Moreover, it can be extended using Plugins that can be installed directly from the MarketPlace in VSCode.

How to install

Installing VSCode in linux is a simple task. Just downkload the .deb package from its webpage and follow the installation intructions given by the program.

Installing plugins

The installation of plugins for VSCode has been simplified thanks to the integration of the MarketPlace inside VSCode. After clicking on the Plugins tab, search for the desire Plugin and click install to set it up in your VSCode automatically.

Git

VSCode brings integration by default, so it is not needed to configure anything extra after the installation. However, many plugins extend the functionalities of Git in VSCode in case the user misses some functionality.

Debugging a program

COnfiguring the debugger in VSCode requires to define two .json files (one to enable building Xmipp within the VSCode framework and the other to specify the executable to be debuged among other options).

The structure of the tasks.json file needed to build Xmipp is the following:

{

  "version": "2.0.0",

    "command": "${env:HOME}/scipion/xmipp-bundle/xmipp",

    "type": "shell",

    "tasks": [

        {

            "label": "Xmipp Compile",

            "group": "build",

            "presentation": {

                "reveal": "always"

            },

            "args": [

                "compileAndInstall",

                "Number_Processors"

            ],

            "problemMatcher": []

        }

    ]

}

Note that this file assumes that the path to Xmipp is within Scipion folder (usual case when Xmipp is installed during the Scipion3 installation).

In order to debug a given executable, the following launch.json is proposed:

{

    "version": "0.2.0",

    "configurations": [

        {

            "name": "(gdb) Launch",

            "type": "cppdbg",

            "request": "launch",

            "program": "${workspaceFolder}/Path/To/Executable",

            "args": ["arguments_of_the_program"],

            "stopAtEntry": false,

            "cwd": "${workspaceFolder}",

            "environment": [{"name": "LD_LIBRARY_PATH", "value": "Path/To/Scipion/software/lib:Path/To/Xmipp/build/lib:Path/To/Xmipp/build/bindings/python:"},
                            {"name": "PYTHONPATH", "value": "Path/To/Xmipp/build/bindings/python:Path/To/Xmipp/build/pylib:"},
                            {"name": "XMIPP_HOME", "value": "Path/To/Xmipp/build"},
                            {"name": "XMIPP_NOSCIPION", "value": "True"},
                            {"name": "XMIPP_SRC", "value": "Path/To/Xmipp/src"}],

            "externalConsole": false,

            "MIMode": "gdb",

            "setupCommands": [

                {

                    "description": "Enable pretty-printing for gdb",

                    "text": "-enable-pretty-printing",

                    "ignoreFailures": true

                }

            ]

        }

    ]

}

As before, the path to the executable provided asumes that the whole Xmipp has been opened in VSCode as the workspace folder. In most of the cases, the executable are located within the folder build/bin.

Clone this wiki locally