athackst / vscode_ros2_workspace

A template for using VSCode as an IDE for ROS2 development.

Home Page:https://althack.dev/vscode_ros2_workspace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: how to source setup.bash before press F5 launch launch.json

oridong opened this issue · comments

commented

how to source setup.bash before press F5 launch launch.json ? the shell where gdb running must has the foxy environment variables, otherwise

error while loading shared libraries: librclcpp.so: cannot open shared object file: No such file or directory

Are you using the provided dockerfile or did you roll your own?

I think you have 2 options here:

  1. Either the shell environment has the appropriate environment variables set up
  2. You add a pre-launch task to source setup.bash

launch.json

    // Example gdb launch of a ros executable
    {
      "name": "(gdb) Launch (merge-install)",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/install/lib/${input:package}/${input:program}",
      "args": [],
      "preLaunchTask": "source",
      "stopAtEntry": true,
      "cwd": "${workspaceFolder}",
      "externalConsole": false,
      "MIMode": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    },

tasks.json

        {
            "label": "source",
            "detail": "Source the directory",
            "type": "shell",
            "command": "source install/setup.bash", // path to your setup.bash file
            "problemMatcher": []
        }