C++ Setup
You will need a working C++ compiler capable of compiling C++11 code. To get it:
- On Windows, install Rtools.
- On Mac, install Xcode from the App Store.
- On Linux,
sudo pacman -Syu install build-essential g++-11
or similar.
For Ubuntu Users
After installing g++-11
, you may still encounter issues
compiling C++ code due to missing standard library headers. This does
not happen when testing on Manjaro Linux.
You can try this:
Then you can attempt to compile a simple example to print a number:
// save this as 01-print-number.cpp or similar
#include <iostream> // required for the cout function
// function to print a message
int main() {
std::cout << 1 << std::endl;
return 0;
}
Then try to compile and run it with the following bash instruction:
Otherwise, not installing the additional packages may lead to the following error:
R Setup
You can install the R packages bench
,
cpp4r
, devtools
and usethis
with
the following command:
install.packages(c("bench", "cpp4r", "devtools", "usethis"))
To verify that R can compile C++ code, you can run
pkgbuild::check_build_tools(debug = TRUE)
, which will
return an output similar to: