Low-level R library bindings
To build this library and test that everything is working as expected, run the following two commands in the library's top-level directory:
bash
cargo build
cargo test
The build script has the following two dependencies:
LIBCLANG_PATH
environment variable or add llvm-config
to your search path.Set LIBCLANG_PATH
to the lib
directory of your llvm
installation. E.g.,
LIBCLANG_PATH=/usr/lib/llvm-3.9/lib
.
Ensure the preferred R binaries, are part of the PATH
, e.g. C:/R/R-4.0.2/bin/x64
.
For information on how to add environment variables on Windows, see here.
Add the mingw toolchains that are used to build R:
bash
rustup target add x86_64-pc-windows-gnu
rustup target add i686-pc-windows-gnu
The default toolchain must be (stable|beta|nightly)-gnu
, e.g. to set the default
toolchain to be nightly mingw:
bash
rustup default nightly-gnu
Install MSYS2
. Using scoop it is done by
bash
scoop install msys2
To complete the installation, run msys2
once, then restart the terminal.
Run msys2
again, and install Clang and mingw-toolchain via
bash
pacman -S --noconfirm mingw-w64-x86_64-clang mingw-w64-x86_64-toolchain
pacman -S --noconfirm mingw32/mingw-w64-i686-clang mingw-w64-i686-toolchain
Add environment variable LIBCLANG_PATH
with the value pointing to where the
clang binaries are placed. If scoop was used then the path would be:
%USERPROFILE%\scoop\apps\msys2\current\mingw64\bin
.
Then from now on, in order to build this, use:
bash
mingw64
cargo build
cargo test
In order to build it without having to enter a mingw64
/mingw32
shell, then add these
paths to PATH
:
bash
%USERPROFILE%\scoop\apps\msys2\current\usr\bin
%USERPROFILE%\scoop\apps\msys2\current\mingw64\bin # change this to mingw32
Install llvm-config
via homebrew with:
bash
brew install llvm
Add it to your search path via:
bash
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
If you want to compile libR-sys
from within RStudio, you may also have to add the following line to your .Renviron
file:
bash
PATH=/usr/local/opt/llvm/bin:${PATH}