[Rcpp-devel] How to retrieve a flag set in Makevars.in or set the flag as a global variable?

Dirk Eddelbuettel edd at debian.org
Sat Aug 15 14:45:43 CEST 2020

Hi Akshit,

On 15 August 2020 at 17:53, Akshit Achara wrote:
| I have created an R package(rminizinc
| <https://github.com/acharaakshit/RMiniZinc>) which uses Rcpp. I have a
| configure.ac file to set up the paths in my Makevars.in which looks like
| this:

You already posted this at StackOverflow. I saw it, but didn't respond as it
seemed to both have a) little to do with Rcpp and b) may be an 'XY Problem'.
| OBJECTS.tests = cpp_tests/test-runner.o cpp_tests/test-mzn_parse.o
| cpp_tests/test-
| set_params.o cpp_tests/test-mzn_eval.o cpp_tests/test-sol_parse.o
| cpp_tests/test-
| getMissingPars.o
| OBJECTS.sources = RcppExports.o set_params.o mzn_parse.o mzn_eval.o sol_parse.o
| getMissingPars.o
| OBJECTS.helpers = filetoString.o helper_parse.o expDetails.o pathStringcheck.o
| OBJECTS = $(OBJECTS.sources) $(OBJECTS.tests) $(OBJECTS.helpers)
| $(SOURCES:.cpp=.o)
| strippedLib: $(SHLIB)
|     if test -e "/usr/bin/strip"; then /usr/bin/strip --strip-debug
| $(SHLIB); fi.phony: strippedLib
| all: clean
| clean:
|     rm -f $(OBJECTS.sources) $(OBJECTS.tests) $(OBJECTS.helpers)  *.so
| I want to use the path provided to PKG_LIBS flag in one of my scripts.
| Is there any way I could set this flag as a global variable so that I
| can read it the script or if it's not possible, how can I extract this
| flag from inside R? Sys.getenv() doesn't give the values for PKG_LIBS.

It is still not clear what you want and why, and it still has little to do
with Rcpp, but some with a (maybe misunderstood ?) way of setting up a
package structure.

For questions about 'how do I built a package with ....' under a specific
perceived or real constraint you could try the the r-package-devel list.
Before you do that I would recommend thinking about the problem and maybe
trying to explain it another way. From what you wrote now twice I still have
no real idea what (and why) you want to do something.

If this is about picking a configuration value (such as the at PKG_LIBS which
change per installation), yes one can capture that in configure and then pass
it to an R or a C/C++ source file. That is what configure does well. Then
again you don't have as the Makevars snippet is read _by the same R process_
and you could just extract .libPaths() from src/Makevars (invoking Rscript or

Good luck.


https://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org

More information about the Rcpp-devel mailing list