LdFlagsFile: Write VTK linker flags to a response file

View source: R/vtk.R

LdFlagsFileR Documentation

Write VTK linker flags to a response file

Description

On Windows the full set of VTK linker flags can exceed the 8 191-character Windows command-line limit, causing the linker to drop flags at the end of the list. This function writes the flags to a plain-text response file that the linker reads via the ⁠@file⁠ syntax, keeping the command line short.

Usage

LdFlagsFile(path, os_type = .Platform$OS.type)

Arguments

path

Path (relative to the package source root, i.e. where configure runs) to the response file to write on Windows, e.g. "src/vtk_libs.rsp". Ignored on non-Windows platforms.

os_type

A string identifying the operating-system type, defaulting to .Platform$OS.type. Override to "windows" or "unix" in tests to exercise the Windows response-file branch without needing a Windows environment.

Details

Intended to be called from a downstream package's configure or configure.win script:

VTK_LIBS="$("${R_HOME}/bin/Rscript" --vanilla -e \
  "rvtk::LdFlagsFile('src/vtk_libs.rsp')")"
# VTK_LIBS is now the short string "@src/vtk_libs.rsp" on Windows,
# or the raw flags on macOS/Linux.

On Windows the flags are written to path and the function returns the ⁠@basename(path)⁠ token for the linker. On macOS and Linux, ld does not reliably support ⁠@file⁠ response files at the compiler-driver level, so no file is written and the raw flags are returned directly.

Value

Invisibly, the string to embed in configure (either ⁠@basename(path)⁠ on Windows or the raw flags on other platforms). The string is also written to stdout so that shell command substitution captures it.

Examples

rsp <- file.path(tempdir(), "vtk_libs.rsp")
ref <- LdFlagsFile(rsp)

rvtk documentation built on May 11, 2026, 9:09 a.m.