microsoft / microsoft-r-open

Microsoft R Open Source
212 stars 69 forks source link

Failed to compile Rcpp based packages #17

Closed giantwhale closed 7 years ago

giantwhale commented 7 years ago

I couldn't compile Rcpp-based package RcppBDT on two of my PCs, one uses CentOS and the other uses Ubuntu. The errors are the same. (I can compile some other Rcpp-based packages though)

Here's the link to the original post: https://github.com/eddelbuettel/rcppbdt/issues/3

The problem is weird. R is supposed to compile c++ source scripts with something like

g++ -I/usr/lib64/microsoft-r/3.3/include ...

However, it removed the first part of the above command and run the following instead

I/user/lib64/microsoft-r/3.3/include ...

Then I got a No File Found error, because there's no file named I/user/lib64/microsoft-r/3.3/include

nathansoz commented 7 years ago

This is related to #11 and is a side effect of how we compile microsoft-r-open. A temporary workaround is to download the package source and edit: src/Makevars

Remove:

CXX_STD = CXX11

And then edit the PKG_CPPFLAGS line to looks like this:

PKG_CPPFLAGS = -I../inst/include/ -std=c++11

eddelbuettel commented 7 years ago

@nathansoz The strategy if jumping away from the default compiler which R used may lead to a number of similar build surprises. It may be a lot easier to stick with compilers R picked...

nathansoz commented 7 years ago

As far as I know, there is no "default compiler" for R on Linux (whereas I know there is a specified toolchain for Windows that we use). Can you point me to documentation that specifies a default compiler for R on Linux? I'd be happy to consider it in the 3.3.3 release if this is the case.

We are for sure going to upgrade to a compiler that has c++11 support in that release, but we are trying to also balance backwards compatibility concerns as we release a single binary for all platforms.

Edit: I went into more detail in #11 where I also replied. Let's continue that discussion there. I'll close this issue for now as this and #11 have the same root cause.

eddelbuettel commented 7 years ago

there is no "default compiler" for R on Linux

You have the question backwards:

tar xfz R_*tar.gz  # some release
configure       # lots of options
make
make install

will work with just about any compiler version -- that is what configure.

BUT that compiler version and its capabilities are then encoded.

You play a risky game by messing. You can, however, override with a suitable set of arguments in the system Makeconf or a level above (via env.vars). It is doable, but a ton of things may break and you get to pick up the pieces. Just test this real well.