flags: Compiler and linker flags for the bundled Ceres Solver

CxxFlagsR Documentation

Compiler and linker flags for the bundled Ceres Solver

Description

CxxFlags() and LdFlags() return the flags needed to compile and link C++ code against the Ceres Solver library that is built and installed with this package. inlineCxxPlugin() is the plugin used by sourceCpp when a source file contains // [[Rcpp::depends(ceres)]].

Usage

CxxFlags(print = TRUE)
LdFlags(print = TRUE)
inlineCxxPlugin(...)

Arguments

print

if TRUE, the flags are also printed with cat(), which is what a Makevars file needs.

...

ignored.

Details

In a package that uses Ceres, add ceres, RcppEigen and Rcpp to LinkingTo and use the following in src/Makevars:

CXX_STD = CXX17
PKG_LIBS = $(shell "${R_HOME}/bin/Rscript" -e "ceres::LdFlags()")

Value

CxxFlags() and LdFlags() invisibly return the flags as a character string. inlineCxxPlugin() returns a list of settings for sourceCpp.

Examples

CxxFlags()
LdFlags()

if (requireNamespace("RcppEigen", quietly = TRUE)) {
  Rcpp::sourceCpp(system.file("examples", "curve_fitting.cpp",
                              package = "ceres"),
                  env = new.env())
}


ceres documentation built on Nov. 28, 2026, 1:07 a.m.