Bindings for the Visualization Toolkit ('VTK')

Makes the Visualization Toolkit ('VTK') available to R packages so their C++ code can link against it without requiring users to install 'VTK' manually. When no suitable system installation is found, pre-built static libraries are downloaded automatically. Downstream packages declare 'Imports: rvtk' and obtain the correct compiler and linker flags at install time from CppFlags(), LdFlags(), and LdFlagsFile(); the use_rvtk() helper writes all required build-time files in one step. Pre-built libraries cover all VTK modules that can be built without external dependencies, and downstream packages can opt in to linking only the modules they need.


rvtk

R-CMD-check Codecov testcoverage pkgdown CRANstatus

rvtk is an infrastructure package for R package developers: it makes the Visualization Toolkit (VTK) available to R packages that need to link against it from C++. Your users never install VTK themselves — rvtk finds a system VTK when one is present and otherwise downloads pre-built libraries automatically at install time.

Add Imports: rvtk to your DESCRIPTION, then configure your package in one step from the package root:

rvtk::use_rvtk()

use_rvtk() writes src/Makevars, src/Makevars.win, and tools/configure.R so that the compiler and linker flags are resolved at install time via rvtk::CppFlags() and rvtk::LdFlagsFile(). Everything can also be set up by hand — the two approaches produce identical files.

Pre-built libraries are provided for macOS (arm64 and x86_64), Linux (x86_64 glibc, x86_64 musl/Alpine, aarch64, and a clang -stdlib=libc++ variant of x86_64 glibc), and Windows (static or shared DLLs). rvtk’s configure script detects the compiler’s C++ standard library and picks the matching Linux archive automatically.

ABI compatibility of the pre-built libraries. The pre-built archives are compiled with GCC and libstdc++ (on Windows, the Rtools45 static.posix MinGW toolchain), except for the dedicated Linux x86_64 libc++ archive built with Clang. Downstream packages should use a matching toolchain: linking the libstdc++ archive with Clang -stdlib=libc++ fails to load with an undefined __try_use_facet symbol, and linking with a much newer GCC than the build toolchain may fail with __cxa_call_terminate. On Linux x86_64, configure detects which standard library the compiler targets and downloads the matching archive; on other platforms, install a system VTK (e.g. via Homebrew or apt) if your toolchain cannot match the bundled one.

Which VTK modules are available

The pre-built archives bundle all VTK modules that can be built without external dependencies (160 static libraries, including the Viskores acceleration modules). Downstream packages can opt in to link against only the modules they need — pass the modules argument to use_rvtk() or LdFlags()/LdFlagsFile() to reduce link time and storage footprint:

# link only what your C++ code uses
rvtk::use_rvtk(modules = c("CommonCore", "CommonDataModel", "IOLegacy"))

With a system VTK installation, rvtk records which modules are available on that machine and hard-fails at install time if a downstream package requests a module that is not present — instead of failing later with a confusing linker error. rvtk::available_modules() lists the modules of the VTK that rvtk resolved to.

See the vignette for full details: how VTK is located on each platform (with the compatibility matrix), which VTK modules are bundled, manually writing the build files, and restricting linking with the modules argument.

Quick start

# Install rvtk (from CRAN, or the development version)
install.packages("rvtk")
# pak::pak("astamm/rvtk")

# From the root of your downstream package:
rvtk::use_rvtk()

Then use rvtk::CppFlags(), rvtk::LdFlags(), rvtk::LdFlagsFile(), and rvtk::VtkVersion() in your build scripts or configure when you need finer control.

Installation

# from CRAN
install.packages("rvtk")

# development version
# install.packages("pak")
pak::pak("astamm/rvtk")

A system VTK installation (≥ 9.1.0) is not required: if none is found the package downloads pre-built libraries automatically.

Links

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rvtk")

0.3.0 by Aymeric Stamm, a day ago


https://github.com/astamm/rvtk, https://astamm.github.io/rvtk/


Report a bug at https://github.com/astamm/rvtk/issues


Browse source code at https://github.com/cran/rvtk


Authors: Aymeric Stamm [aut, cre, cph] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Suggests cli, knitr, quarto, tinytest


Imported by riot.


See at CRAN