0

I am trying to reproduce the example here to debug RCPP code with VS Code on Windows.

Here is my launch.json config:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug R Package",
      "type": "cppdbg",
      "request": "launch",
      "program": "C:/Users/<USER>/AppData/Local/Programs/R/R-4.2.1/bin/x64/R",
      "args": [
        "--vanilla",
        "-e",
        "devtools::test()"
      ],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "C:/msys64/ucrt64/bin/gdb.exe",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        },
      ],
      "preLaunchTask": "debug",
    }
  ]
}

Here is the c_cpp_properties.json config:

{
    "configurations": [
      {
        "name": "Win32",
        "includePath": [
          "${workspaceFolder}/**",
          "C:/rtools40/mingw64/include",
          "C:/rtools40/mingw64/include/c++/8.3.0",
          "C:/rtools40/mingw64/include/c++/8.3.0/x86_64-w64-mingw32",
          "C:/Users/<USER>/AppData/Local/Programs/R/R-4.2.1/include",
          "C:/Users/<USER>/AppData/Local/Programs/R/R-4.2.1/library/Rcpp/include",
          "C:/Users/<USER>/AppData/Local/Programs/R/R-4.2.1/library/RcppArmadillo/include"
        ],
        "defines": [
          "_DEBUG",
          "UNICODE",
          "_UNICODE"
        ],
        "windowsSdkVersion": "10.0.19041.0",
        "compilerPath": "C:/msys64/ucrt64/bin/g++.exe",
        "cStandard": "c11",
        "cppStandard": "c++17",
        "intelliSenseMode": "gcc-x64"
      }
    ],
    "version": 4
  }

But when I try to debug, the code executes but does not stop at breakpoints.

I have tried to put calc_sum(c(1, 2, 3)) in tools\test.R and change the launch config with:

"args": [
    "--vanilla",
    "-e",
    "devtools::load_all();source('tools/test.R)'"
],

but that does not work either, the debugger does not stop at breakpoints.

Any idea what I may be doing wrong?

7
  • I'm not sure that this is supported on Windows. See the GitHub issue, running example on Windows. Commented Aug 12, 2024 at 12:27
  • 1
    Alright, I will try to make it work on Linux then, thanks! Commented Aug 13, 2024 at 9:02
  • in my experience Rcpp is kind of a pain on Windows (especially in corporate environments where directories such as OneDrive are forced to have spaces in them) but works beautifully on WSL2. Commented Aug 13, 2024 at 11:12
  • Yep I've just managed to make it work on WSL2, was very straightforward. Thanks again for your help! Commented Aug 13, 2024 at 12:29
  • 1
    @SamR You point the finger at Rcpp when you should point the finger at R and its use of gcc via MinGW. Great tools. but pretty alien to everything customized to Visual Studio / Visual Code under Windows. WSL2 is indeed a great helper there. Commented Aug 19, 2024 at 13:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.