Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set up CPPFLAGS with cpp11::cpp_source #246

Open
vspinu opened this issue Oct 27, 2021 · 3 comments
Open

How to set up CPPFLAGS with cpp11::cpp_source #246

vspinu opened this issue Oct 27, 2021 · 3 comments

Comments

@vspinu
Copy link
Contributor

vspinu commented Oct 27, 2021

Sorry if obvious, but I cannot figure out a way to provide compiler flags to cpp_soruce besides modifying the ~/.R/Makevars. A local Makevars file is not picked up.

@jimhester
Copy link
Member

You should be able to set the environment variable R_MAKEVARS_USER to wherever you want it to be if you don't want to use the site wide makevars file. see https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Customizing-package-compilation

There isn't anything built into cpp11 to make this easier however.

@vspinu
Copy link
Contributor Author

vspinu commented Oct 27, 2021

Thanks! I learned something new today.

Would it make sense for cpp11 to pick the Makevars in the working directory automatically? Similarly how the Makevars within packages works I would suggest.

@paleolimbot
Copy link
Contributor

You can also temporarily set the PKG_CPPFLAGS environment variable (totally unverified hack on my end). For example, I use this to prototype C++ linking to my local development version of Arrow:

withr::with_envvar(
  list(
    PKG_CXXFLAGS = paste0("-I", Sys.getenv("ARROW_HOME"), "/include"),
    PKG_LIBS = paste0("-L", Sys.getenv("ARROW_HOME"), "/lib", " -larrow")
  ),
  cpp11::cpp_source("2021_11_05_copy_files.cpp")
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants