Discussion:
[Rcpp-devel] C++11 Solaris cmath/math.H
Jan Wijffels
2017-09-06 13:03:40 UTC
Permalink
Hello,

I'm trying to fix the installation issue I have with the package udpipe:
https://github.com/bnosac/udpipe but I'm getting issues on Solaris giving
messages like this:

/opt/csw/bin/g++ -std=gnu++11
-I/opt/R/R-3.4.1-patched-gcc/lib/R/include -DNDEBUG
-I"/export/home/XyG0aYI/R/Rcpp/include" -I/opt/csw/include
-I/usr/local/include -fPIC -O2 -c RcppExports.cpp -o RcppExports.o
In file included from /opt/csw/include/c++/5.2.0/cmath:44:0,
from
/export/home/XyG0aYI/R/Rcpp/include/Rcpp/platform/compiler.h:100,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp/r/headers.h:48,
from /export/home/XyG0aYI/R/Rcpp/include/RcppCommon.h:29,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp.h:27,
from RcppExports.cpp:4:
/usr/include/math.h:45:12: error: ‘std::float_t’ has not been declared
using std::float_t;
^
/usr/include/math.h:46:12: error: ‘std::double_t’ has not been declared
using std::double_t;

This type of error seems to be something that has been mentioned in
https://journal.r-project.org/archive/2011-2/RJournal_2011-2_Plummer.pdf
but still can't seem to find the solution.

To make this problem as tiny as possible, I've made a reproducible example.
Let's say I have an R package with the following inside the src folder

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::plugins(cpp11)]]
CharacterVector na_locf(CharacterVector x) {
return x;
}

If the DESCRIPTION file mentions the following:

Imports: Rcpp (>= 0.12.12)
LinkingTo: Rcpp
SystemRequirements: C++11

Or if there is CXX_STD=CXX11 in the Makevars file, I get the errors like
this when building on Solaris (see log on
https://builder.r-hub.io/status/original/ttt_0.1.0.tar.gz-26c279a1b07047fea8ded89b4e07c6ad),
using rhub::check(platform = "solaris-x86-patched"), while on Ubuntu this
is working fine.

/opt/csw/bin/g++ -std=gnu++11
-I/opt/R/R-3.4.1-patched-gcc/lib/R/include -DNDEBUG
-I"/export/home/XyG0aYI/R/Rcpp/include" -I/opt/csw/include
-I/usr/local/include -fPIC -O2 -c RcppExports.cpp -o RcppExports.o
In file included from /opt/csw/include/c++/5.2.0/cmath:44:0,
from
/export/home/XyG0aYI/R/Rcpp/include/Rcpp/platform/compiler.h:100,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp/r/headers.h:48,
from /export/home/XyG0aYI/R/Rcpp/include/RcppCommon.h:29,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp.h:27,
from RcppExports.cpp:4:
/usr/include/math.h:45:12: error: ‘std::float_t’ has not been declared
using std::float_t;

I
​f I do not add ​SystemRequirements: C++11 and remove the Makevars file,
this works fine on Solaris. I need however C++11 as I need it in the udpipe
R package for building udpipe.cpp but can't add
to that udpipe.cpp file the following types of statements due to conflicts
on the use of the Free macro.
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::plugins(cpp11)]]

Is there anyone having similar problems that can give an indication on how
to solve this Solaris build issue?

many thanks,
Jan



Jan Wijffels
Statistician
www.bnosac.be | +32 486 611708
Jan Wijffels
2017-09-06 13:10:49 UTC
Permalink
Small update on this question. The issue appears when exporting the Rcpp
function and the error messages are caused by RcppExports.cpp
which is generated when running Rcpp::compileAttributes()

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::export]]
CharacterVector na_locf(CharacterVector x) {
return x;
}

This is the output from Rcpp::compileAttributes()

#include <Rcpp.h>

using namespace Rcpp;

// na_locf
CharacterVector na_locf(CharacterVector x);
RcppExport SEXP _ttt_na_locf(SEXP xSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< CharacterVector >::type x(xSEXP);
rcpp_result_gen = Rcpp::wrap(na_locf(x));
return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_ttt_na_locf", (DL_FUNC) &_ttt_na_locf, 1},
{NULL, NULL, 0}
};

RcppExport void R_init_ttt(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}

My excuses for this update.

Jan


Jan Wijffels
Statistician
www.bnosac.be | +32 486 611708
Post by Jan Wijffels
Hello,
https://github.com/bnosac/udpipe but I'm getting issues on Solaris giving
/opt/csw/bin/g++ -std=gnu++11 -I/opt/R/R-3.4.1-patched-gcc/lib/R/include -DNDEBUG -I"/export/home/XyG0aYI/R/Rcpp/include" -I/opt/csw/include -I/usr/local/include -fPIC -O2 -c RcppExports.cpp -o RcppExports.o
In file included from /opt/csw/include/c++/5.2.0/cmath:44:0,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp/platform/compiler.h:100,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp/r/headers.h:48,
from /export/home/XyG0aYI/R/Rcpp/include/RcppCommon.h:29,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp.h:27,
/usr/include/math.h:45:12: error: ‘std::float_t’ has not been declared
using std::float_t;
^
/usr/include/math.h:46:12: error: ‘std::double_t’ has not been declared
using std::double_t;
This type of error seems to be something that has been mentioned in
https://journal.r-project.org/archive/2011-2/RJournal_2011-2_Plummer.pdf
but still can't seem to find the solution.
To make this problem as tiny as possible, I've made a reproducible
example. Let's say I have an R package with the following inside the src
folder
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::plugins(cpp11)]]
CharacterVector na_locf(CharacterVector x) {
return x;
}
Imports: Rcpp (>= 0.12.12)
LinkingTo: Rcpp
SystemRequirements: C++11
Or if there is CXX_STD=CXX11 in the Makevars file, I get the errors like
this when building on Solaris (see log on https://builder.r-hub.io/
status/original/ttt_0.1.0.tar.gz-26c279a1b07047fea8ded89b4e07c6ad), using
rhub::check(platform = "solaris-x86-patched"), while on Ubuntu this is
working fine.
/opt/csw/bin/g++ -std=gnu++11 -I/opt/R/R-3.4.1-patched-gcc/lib/R/include -DNDEBUG -I"/export/home/XyG0aYI/R/Rcpp/include" -I/opt/csw/include -I/usr/local/include -fPIC -O2 -c RcppExports.cpp -o RcppExports.o
In file included from /opt/csw/include/c++/5.2.0/cmath:44:0,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp/platform/compiler.h:100,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp/r/headers.h:48,
from /export/home/XyG0aYI/R/Rcpp/include/RcppCommon.h:29,
from /export/home/XyG0aYI/R/Rcpp/include/Rcpp.h:27,
/usr/include/math.h:45:12: error: ‘std::float_t’ has not been declared
using std::float_t;
I
​f I do not add ​SystemRequirements: C++11 and remove the Makevars file,
this works fine on Solaris. I need however C++11 as I need it in the udpipe
R package for building udpipe.cpp but can't add
to that udpipe.cpp file the following types of statements due to conflicts
on the use of the Free macro.
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::plugins(cpp11)]]
Is there anyone having similar problems that can give an indication on how
to solve this Solaris build issue?
many thanks,
Jan
Jan Wijffels
Statistician
www.bnosac.be | +32 486 611708
Dirk Eddelbuettel
2017-09-06 16:49:36 UTC
Permalink
Hi Jan,

On 6 September 2017 at 15:03, Jan Wijffels wrote:
| I'm trying to fix the installation issue I have with the package udpipe:
| https://github.com/bnosac/udpipe but I'm getting issues on Solaris giving
| messages like this:

Solaris no longer really matters.

| If I do not add ​SystemRequirements: C++11 and remove the Makevars file,
| this works fine on Solaris.

You could add C++11 conditionally, ie only on Linux/macOS/Windows. You could
use (even a shell script named) configure for that.

| I need however C++11 as I need it in the udpipe
| R package for building udpipe.cpp but can't add
| to that udpipe.cpp file the following types of statements due to conflicts
| on the use of the Free macro.
| #include <Rcpp.h>
| using namespace Rcpp;
| // [[Rcpp::plugins(cpp11)]]

Can you explain a bit more? What Free macro? Do you know about forcing R to
add Rf_ to its macros?

Also [[Rcpp::plugins(cpp11)]] should not be needed in a package.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Jan Wijffels
2017-09-10 20:35:06 UTC
Permalink
Solaris no longer really matters.
Does that mean that CRAN will accept a package which gives errors on
Solaris?

You could add C++11 conditionally, ie only on Linux/macOS/Windows
Yes, but I always need C++11 for this package. I just wanted to make a
small reproducible example. The bigger reproducible example is the package
at https://github.com/bnosac/udpipe

If I add the Rcpp.h header to file
https://github.com/bnosac/udpipe/blob/master/src/udpipe.cpp, I'm getting
issues similar to this

udpipe.cpp:23406:30: error: macro "Free" passed 2 arguments, but takes just 1
alloc->Free(alloc, p->probs);


​ Also [[Rcpp::plugins(cpp11)]] should not be needed in a package.
Thank you for the remark. The udpipe package currently uses CXX_STD=CXX11
in Makevars and specifies SystemRequirements: C++11 in DESCRIPTION. Example
was just put there to show a minimal example of the error, coming from when
Rcpp compiles the attributes.

If you could provide a pointer where I should look for a solution, this
would be great otherwise the package which is now on CRAN will be rejected
any time soon I think.

best,
Jan






Jan Wijffels
Statistician
www.bnosac.be | +32 486 611708
Post by Dirk Eddelbuettel
Hi Jan,
| https://github.com/bnosac/udpipe but I'm getting issues on Solaris giving
Solaris no longer really matters.
| If I do not add ​SystemRequirements: C++11 and remove the Makevars file,
| this works fine on Solaris.
You could add C++11 conditionally, ie only on Linux/macOS/Windows. You could
use (even a shell script named) configure for that.
| I need however C++11 as I need it in the udpipe
| R package for building udpipe.cpp but can't add
| to that udpipe.cpp file the following types of statements due to conflicts
| on the use of the Free macro.
| #include <Rcpp.h>
| using namespace Rcpp;
| // [[Rcpp::plugins(cpp11)]]
Can you explain a bit more? What Free macro? Do you know about forcing R to
add Rf_ to its macros?
Also [[Rcpp::plugins(cpp11)]] should not be needed in a package.
Dirk
--
Dirk Eddelbuettel
2017-09-11 11:28:30 UTC
Permalink
Jan: This is hard/impossible for me to read. I do not use a html email
client, so if you used colour here, I don't see. Please use indentation if
you can.

On 10 September 2017 at 22:35, Jan Wijffels wrote:
| Solaris no longer really matters.
| Does that mean that CRAN will accept a package which gives errors on
| Solaris?

I don't know. Only CRAN can speak to that. But Solaris no exists (as an
Oracle product) and is no longer maintained at U Oxford meaning CRAN may noe
have test machines any more.

|
| You could add C++11 conditionally, ie only on Linux/macOS/Windows
| Yes, but I always need C++11 for this package. I just wanted to make a
| small reproducible example. The bigger reproducible example is the package
| at https://github.com/bnosac/udpipe

Fine, then use it. I use CXX_STD=CXX11 in many of my packages too.

| If I add the Rcpp.h header to file
| https://github.com/bnosac/udpipe/blob/master/src/udpipe.cpp, I'm getting
| issues similar to this
|
| udpipe.cpp:23406:30: error: macro "Free" passed 2 arguments, but takes just 1
| alloc->Free(alloc, p->probs);

Quite possibly not a Solaris issue but a simply _ordering issue_: place
Rcpp.h last, not first, and/or tell R not to define macros. An `#undef`
may help too.

| ​ Also [[Rcpp::plugins(cpp11)]] should not be needed in a package.
| Thank you for the remark. The udpipe package currently uses CXX_STD=CXX11
| in Makevars and specifies SystemRequirements: C++11 in DESCRIPTION. Example

You need one of these two, not both.

| was just put there to show a minimal example of the error, coming from when
| Rcpp compiles the attributes.
|
| If you could provide a pointer where I should look for a solution, this
| would be great otherwise the package which is now on CRAN will be rejected
| any time soon I think.

Try reordering.

Hth, Dirk

|
| best,
| Jan
|
|
|
|
|
|
| Jan Wijffels
| Statistician
| www.bnosac.be | +32 486 611708
|
| On 6 September 2017 at 18:49, Dirk Eddelbuettel <***@debian.org> wrote:
|
| >
| > Hi Jan,
| >
| > On 6 September 2017 at 15:03, Jan Wijffels wrote:
| > | I'm trying to fix the installation issue I have with the package udpipe:
| > | https://github.com/bnosac/udpipe but I'm getting issues on Solaris
| > giving
| > | messages like this:
| >
| > Solaris no longer really matters.
| >
| > | If I do not add ​SystemRequirements: C++11 and remove the Makevars file,
| > | this works fine on Solaris.
| >
| > You could add C++11 conditionally, ie only on Linux/macOS/Windows. You
| > could
| > use (even a shell script named) configure for that.
| >
| > | I need however C++11 as I need it in the udpipe
| > | R package for building udpipe.cpp but can't add
| > | to that udpipe.cpp file the following types of statements due to
| > conflicts
| > | on the use of the Free macro.
| > | #include <Rcpp.h>
| > | using namespace Rcpp;
| > | // [[Rcpp::plugins(cpp11)]]
| >
| > Can you explain a bit more? What Free macro? Do you know about forcing R
| > to
| > add Rf_ to its macros?
| >
| > Also [[Rcpp::plugins(cpp11)]] should not be needed in a package.
| >
| > Dirk
| >
| > --
| > http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
| >
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Jan Wijffels
2017-09-16 09:10:59 UTC
Permalink
Thank you for the feedback. It helped, although not in the direction I had
in mind originally but the proposed directions are equally fine.

many thanks,
Jan


Jan Wijffels
Statistician
www.bnosac.be | +32 486 611708
Post by Dirk Eddelbuettel
Jan: This is hard/impossible for me to read. I do not use a html email
client, so if you used colour here, I don't see. Please use indentation if
you can.
| Solaris no longer really matters.
| Does that mean that CRAN will accept a package which gives errors on
| Solaris?
I don't know. Only CRAN can speak to that. But Solaris no exists (as an
Oracle product) and is no longer maintained at U Oxford meaning CRAN may noe
have test machines any more.
|
| You could add C++11 conditionally, ie only on Linux/macOS/Windows
| Yes, but I always need C++11 for this package. I just wanted to make a
| small reproducible example. The bigger reproducible example is the package
| at https://github.com/bnosac/udpipe
Fine, then use it. I use CXX_STD=CXX11 in many of my packages too.
| If I add the Rcpp.h header to file
| https://github.com/bnosac/udpipe/blob/master/src/udpipe.cpp, I'm getting
| issues similar to this
|
| udpipe.cpp:23406:30: error: macro "Free" passed 2 arguments, but takes just 1
| alloc->Free(alloc, p->probs);
Quite possibly not a Solaris issue but a simply _ordering issue_: place
Rcpp.h last, not first, and/or tell R not to define macros. An `#undef`
may help too.
| ​ Also [[Rcpp::plugins(cpp11)]] should not be needed in a package.
| Thank you for the remark. The udpipe package currently uses CXX_STD=CXX11
| in Makevars and specifies SystemRequirements: C++11 in DESCRIPTION. Example
You need one of these two, not both.
| was just put there to show a minimal example of the error, coming from when
| Rcpp compiles the attributes.
|
| If you could provide a pointer where I should look for a solution, this
| would be great otherwise the package which is now on CRAN will be rejected
| any time soon I think.
Try reordering.
Hth, Dirk
|
| best,
| Jan
|
|
|
|
|
|
| Jan Wijffels
| Statistician
| www.bnosac.be | +32 486 611708
|
|
| >
| > Hi Jan,
| >
| > | https://github.com/bnosac/udpipe but I'm getting issues on Solaris
| > giving
| >
| > Solaris no longer really matters.
| >
| > | If I do not add ​SystemRequirements: C++11 and remove the Makevars
file,
| > | this works fine on Solaris.
| >
| > You could add C++11 conditionally, ie only on Linux/macOS/Windows. You
| > could
| > use (even a shell script named) configure for that.
| >
| > | I need however C++11 as I need it in the udpipe
| > | R package for building udpipe.cpp but can't add
| > | to that udpipe.cpp file the following types of statements due to
| > conflicts
| > | on the use of the Free macro.
| > | #include <Rcpp.h>
| > | using namespace Rcpp;
| > | // [[Rcpp::plugins(cpp11)]]
| >
| > Can you explain a bit more? What Free macro? Do you know about forcing R
| > to
| > add Rf_ to its macros?
| >
| > Also [[Rcpp::plugins(cpp11)]] should not be needed in a package.
| >
| > Dirk
| >
| > --
| >
--
Loading...