Skip to content

Path quoting in CxxFlags with bash #1242

@llaniewski

Description

@llaniewski

Hi. In relation to the discussion in #1188 I just wanted to mention an issue introduced there.

Problem

Adding quotes around path in #1189 broke compilation for anybody who was using CxxFlags in simple compilation script like:

CXXFLAGS="$(R CMD config --cppflags)"
CXXFLAGS="$CXXFLAGS $(R --vanilla --slave -e "Rcpp:::CxxFlags()")"
g++ $CXXFLAGS -c main.cpp

This is because bash will use exactly what is returned by CxxFlags as argument for the compiler (g++). This means that the compiler gets -I"/some/path" and searches for headers in "/some/path" rather then /some/path.

Other use cases

  • You can resolve the quotes in bash by doing eval g++ ... in the script, but one cannot modify the all the compiler calls to use "eval" in eg. ./configure scripts from autoconf.
  • If one uses the CxxFlags() in GNU make, it works. This is because make resolves the quotes. For example, the compilation of RInside examples (example/standard) works fine.
  • On the other hand, it seems to break cmake-based compilation. When I try to compile the same examples using cmake 3.16.3 for configuration, it fails with the error. Apparently passing path with quotes to include_directories() through a variable causes some weird behaviour.

Questions

  • If anybody has a good idea how to fix this without hurting windows users and their beloved spaces, I would be happy to implement it and make a pull request. The only half-decent workaround I can think of now is quoting path if it has a space.
  • Is there a better way to do get include paths from Rcpp, which would work with eg. autoconf?

Notes

We run into this problem, as we use RInside in our C++ code. We currently use a workaround of stripping quotes.

The main.cpp file can be as simple as:

#include <Rcpp.h>
int main () {
    return 0;
}

I'm not attaching sessionInfo() as this issue is not about R.

@eddelbuettel Do you think it is an issue at all and would you expect such a bash script to work? If not, I you can close the issue, and we'll stick with our workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions