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?
Rcppwhen you should point the finger at R and its use ofgccviaMinGW. Great tools. but pretty alien to everything customized to Visual Studio / Visual Code under Windows. WSL2 is indeed a great helper there.