Rstan installation on MacOS Mojave


#1

Operating System: MacOS Mojave (10.14.1)
Interface Version: 2.18.1
Compiler/Toolkit: Xcode 10.1

Since I updated my OS to MacOS Mojave, rstan stopped working.

I tried re-installing it from scratch, but I cannot succeed in installing the macOS R toolchain.
IIn fact, I downloaded the installer from the release page. I tried a few times but kept getting the error.

04

Anyone knows how can I fix it? I was even considering downgrading my OS because none of the fixes suggested around work for me.

Best,
Marco


#2

Not necessary to downgrade an OS. If you have Xcode installed, we can get it to work until the macOS toolchain is updated for Mojave.


#3

I have Xcode 10.1 installed, but the compiler is not working anyway.

Indeed, when I run this codeI fail to get 10:
fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , ' return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ; ' ) fx( 2L, 5 ) # should be 10


#4

What do you get?


#5

This:

fx <- inline::cxxfunction( signature(x = “integer”, y = “numeric” ) , ’

  • return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
  •                        ' )
    

In file included from file50dd5fdfd554.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/usr/local/clang4/bin/…/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file50dd5fdfd554.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/usr/local/clang4/bin/…/include/c++/v1/cmath:316:9: error: no member named ‘isinf’ in the global namespace
using ::isinf;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:317:9: error: no member named ‘isnan’ in the global namespace
using ::isnan;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:318:9: error: no member named ‘isnormal’ in the global namespace
using ::isnormal;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:319:9: error: no member named ‘isgreater’ in the global namespace
using ::isgreater;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:320:9: error: no member named ‘isgreaterequal’ in the global namespace
using ::isgreaterequal;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:321:9: error: no member named ‘isless’ in the global namespace
using ::isless;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:322:9: error: no member named ‘islessequal’ in the global namespace
using ::islessequal;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:323:9: error: no member named ‘islessgreater’ in the global namespace
using ::islessgreater;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:324:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:325:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:557:28: error: expected a qualified name after ‘typename’
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/usr/local/clang4/bin/…/include/c++/v1/cmath:557:37: error: expected ‘;’ at end of declaration
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/usr/local/clang4/bin/…/include/c++/v1/cmath:557:37: error: expected unqualified-id
/usr/local/clang4/bin/…/include/c++/v1/cmath:569:39: error: use of undeclared identifier ‘is_floating_point’
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/usr/local/clang4/bin/…/include/c++/v1/cmath:569:57: error: ‘_A1’ does not refer to a value
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/usr/local/clang4/bin/…/include/c++/v1/cmath:567:17: note: declared here
template
^
/usr/local/clang4/bin/…/include/c++/v1/cmath:569:63: error: definition or redeclaration of ‘value’ cannot name the global scope
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [file50dd5fdfd554.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern “C” {
13: SEXP file50dd5fdfd554( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file50dd5fdfd554( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning(“your C++ program does not return anything”);
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from file50dd5fdfd554.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/usr/local/clang4/bin/…/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/usr/local/clang4/bin/…/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file50dd5fdfd554.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/usr/local/clang4/bin/…/include/c++/v1/cmath:316:9: error: no member named ‘isinf’ in the glo
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file50dd5fdfd554.cpp 2> file50dd5fdfd554.cpp.err.txt’ had status 1

fx( 2L, 5 ) # should be 10
Error in fx(2L, 5) : could not find function “fx”


#6

OK, that is due to having the pre-Mojave file at ~/.R/Makevars . Try this

file.remove("~/.R/Makevars") # we can recreate this if necessary

dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
MAKEVARS <- file.path(dotR, "Makevars")
if (!file.exists(MAKEVARS)) file.create(MAKEVARS)

cat(
  "\nCXX14FLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function  -Wno-unknown-pragmas",
  "CC=clang",
  "CXX14=clang++ -arch x86_64 -ftemplate-depth-256",
  if (!file.exists("/usr/include/stdlib.h"))
    "CPPFLAGS = -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
  file = MAKEVARS, 
  sep = "\n", 
  append = TRUE
)

and then again

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
	return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
' )

fx( 2L, 5 ) # should be 10

#7

I tried, but I get this:
In file included from file50dd4115f812.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file50dd4115f812.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:316:9: error: no member named ‘isinf’ in the global namespace
using ::isinf;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:317:9: error: no member named ‘isnan’ in the global namespace
using ::isnan;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:318:9: error: no member named ‘isnormal’ in the global namespace
using ::isnormal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:319:9: error: no member named ‘isgreater’ in the global namespace
using ::isgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:320:9: error: no member named ‘isgreaterequal’ in the global namespace
using ::isgreaterequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:321:9: error: no member named ‘isless’ in the global namespace
using ::isless;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:322:9: error: no member named ‘islessequal’ in the global namespace
using ::islessequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:323:9: error: no member named ‘islessgreater’ in the global namespace
using ::islessgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:324:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:325:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:28: error: expected a qualified name after ‘typename’
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected ‘;’ at end of declaration
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected unqualified-id
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:39: error: use of undeclared identifier ‘is_floating_point’
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:57: error: ‘_A1’ does not refer to a value
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:561:17: note: declared here
template
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:63: error: definition or redeclaration of ‘value’ cannot name the global scope
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [file50dd4115f812.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern “C” {
13: SEXP file50dd4115f812( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file50dd4115f812( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning(“your C++ program does not return anything”);
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from file50dd4115f812.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file50dd4115f812.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file50dd4115f812.cpp 2> file50dd4115f812.cpp.err.txt’ had status 1


#8

OK, try first doing

Sys.setenv(USE_CXX14 = 1)

then again

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
	return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
' )

fx( 2L, 5 ) # should be 10

#9

I tried, doesn’t work

In file included from file50dd477e4aa7.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file50dd477e4aa7.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:316:9: error: no member named ‘isinf’ in the global namespace
using ::isinf;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:317:9: error: no member named ‘isnan’ in the global namespace
using ::isnan;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:318:9: error: no member named ‘isnormal’ in the global namespace
using ::isnormal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:319:9: error: no member named ‘isgreater’ in the global namespace
using ::isgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:320:9: error: no member named ‘isgreaterequal’ in the global namespace
using ::isgreaterequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:321:9: error: no member named ‘isless’ in the global namespace
using ::isless;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:322:9: error: no member named ‘islessequal’ in the global namespace
using ::islessequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:323:9: error: no member named ‘islessgreater’ in the global namespace
using ::islessgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:324:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:325:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:28: error: expected a qualified name after ‘typename’
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected ‘;’ at end of declaration
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected unqualified-id
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:39: error: use of undeclared identifier ‘is_floating_point’
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:57: error: ‘_A1’ does not refer to a value
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:561:17: note: declared here
template
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:63: error: definition or redeclaration of ‘value’ cannot name the global scope
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [file50dd477e4aa7.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern “C” {
13: SEXP file50dd477e4aa7( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file50dd477e4aa7( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning(“your C++ program does not return anything”);
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from file50dd477e4aa7.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file50dd477e4aa7.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file50dd477e4aa7.cpp 2> file50dd477e4aa7.cpp.err.txt’ had status 1


#10

Interesting. Can you call it with verbose = TRUE as in

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
	return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
', verbose = TRUE )

I just need to see how it is calling the compiler.


#11

Hi, this is the output:

Program source :

1 :
2 : // includes from the plugin
3 : #include <R.h>
4 : #include <Rdefines.h>
5 : #include <R_ext/Error.h>
6 :
7 :
8 : // user includes
9 :
10 :
11 : // declarations
12 : extern “C” {
13 : SEXP file2ed5f0b52b6( SEXP x, SEXP y) ;
14 : }
15 :
16 : // definition
17 :
18 : SEXP file2ed5f0b52b6( SEXP x, SEXP y ){
19 :
20 : return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21 :
22 : Rf_warning(“your C++ program does not return anything”);
23 : return R_NilValue ;
24 : }
25 :
26 :
Compilation argument:
/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file2ed5f0b52b6.cpp 2> file2ed5f0b52b6.cpp.err.txt
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -fPIC -Wall -g -O2 -c file2ed5f0b52b6.cpp -o file2ed5f0b52b6.o
In file included from file2ed5f0b52b6.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file2ed5f0b52b6.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:316:9: error: no member named ‘isinf’ in the global namespace
using ::isinf;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:317:9: error: no member named ‘isnan’ in the global namespace
using ::isnan;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:318:9: error: no member named ‘isnormal’ in the global namespace
using ::isnormal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:319:9: error: no member named ‘isgreater’ in the global namespace
using ::isgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:320:9: error: no member named ‘isgreaterequal’ in the global namespace
using ::isgreaterequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:321:9: error: no member named ‘isless’ in the global namespace
using ::isless;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:322:9: error: no member named ‘islessequal’ in the global namespace
using ::islessequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:323:9: error: no member named ‘islessgreater’ in the global namespace
using ::islessgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:324:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:325:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:28: error: expected a qualified name after ‘typename’
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected ‘;’ at end of declaration
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected unqualified-id
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:39: error: use of undeclared identifier ‘is_floating_point’
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:57: error: ‘_A1’ does not refer to a value
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:561:17: note: declared here
template
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:63: error: definition or redeclaration of ‘value’ cannot name the global scope
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [file2ed5f0b52b6.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern “C” {
13: SEXP file2ed5f0b52b6( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file2ed5f0b52b6( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning(“your C++ program does not return anything”);
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from file2ed5f0b52b6.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file2ed5f0b52b6.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++


#12

If in RStudio you do

file.edit("~/.R/Makevars")

change the line that says

CXX14=clang++ -arch x86_64 -ftemplate-depth-256

to

CXX14=clang++ -arch x86_64 -ftemplate-depth-256 -std=c++1y

and then save and call

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
	return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
', verbose = TRUE )

again. Now what does it say?


#13

Program source :

1 :
2 : // includes from the plugin
3 : #include <R.h>
4 : #include <Rdefines.h>
5 : #include <R_ext/Error.h>
6 :
7 :
8 : // user includes
9 :
10 :
11 : // declarations
12 : extern “C” {
13 : SEXP file2ed541644d7( SEXP x, SEXP y) ;
14 : }
15 :
16 : // definition
17 :
18 : SEXP file2ed541644d7( SEXP x, SEXP y ){
19 :
20 : return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21 :
22 : Rf_warning(“your C++ program does not return anything”);
23 : return R_NilValue ;
24 : }
25 :
26 :
Compilation argument:
/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file2ed541644d7.cpp 2> file2ed541644d7.cpp.err.txt
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -fPIC -Wall -g -O2 -c file2ed541644d7.cpp -o file2ed541644d7.o
In file included from file2ed541644d7.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file2ed541644d7.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:316:9: error: no member named ‘isinf’ in the global namespace
using ::isinf;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:317:9: error: no member named ‘isnan’ in the global namespace
using ::isnan;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:318:9: error: no member named ‘isnormal’ in the global namespace
using ::isnormal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:319:9: error: no member named ‘isgreater’ in the global namespace
using ::isgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:320:9: error: no member named ‘isgreaterequal’ in the global namespace
using ::isgreaterequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:321:9: error: no member named ‘isless’ in the global namespace
using ::isless;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:322:9: error: no member named ‘islessequal’ in the global namespace
using ::islessequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:323:9: error: no member named ‘islessgreater’ in the global namespace
using ::islessgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:324:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:325:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:28: error: expected a qualified name after ‘typename’
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected ‘;’ at end of declaration
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected unqualified-id
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:39: error: use of undeclared identifier ‘is_floating_point’
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:57: error: ‘_A1’ does not refer to a value
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:561:17: note: declared here
template
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:63: error: definition or redeclaration of ‘value’ cannot name the global scope
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [file2ed541644d7.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern “C” {
13: SEXP file2ed541644d7( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file2ed541644d7( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning(“your C++ program does not return anything”);
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from file2ed541644d7.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file2ed541644d7.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++


#14

OK, it is definitely failing to pick up on the C++14 standard, which is weird if you did Sys.setenv(USE_CXX14 = 1). Try doing

file.edit("~/.R/Makevars")

and add a line that says

CXX = clang++ -std=c++14

and then call

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
	return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
', verbose = TRUE )

again.


#15

Unfortunately, I still get this:

Program source :

1 :
2 : // includes from the plugin
3 : #include <R.h>
4 : #include <Rdefines.h>
5 : #include <R_ext/Error.h>
6 :
7 :
8 : // user includes
9 :
10 :
11 : // declarations
12 : extern “C” {
13 : SEXP file2ed201aa62( SEXP x, SEXP y) ;
14 : }
15 :
16 : // definition
17 :
18 : SEXP file2ed201aa62( SEXP x, SEXP y ){
19 :
20 : return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21 :
22 : Rf_warning(“your C++ program does not return anything”);
23 : return R_NilValue ;
24 : }
25 :
26 :
Compilation argument:
/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file2ed201aa62.cpp 2> file2ed201aa62.cpp.err.txt
clang++ -std=c++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -fPIC -Wall -g -O2 -c file2ed201aa62.cpp -o file2ed201aa62.o
In file included from file2ed201aa62.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file2ed201aa62.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:316:9: error: no member named ‘isinf’ in the global namespace
using ::isinf;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:317:9: error: no member named ‘isnan’ in the global namespace
using ::isnan;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:318:9: error: no member named ‘isnormal’ in the global namespace
using ::isnormal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:319:9: error: no member named ‘isgreater’ in the global namespace
using ::isgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:320:9: error: no member named ‘isgreaterequal’ in the global namespace
using ::isgreaterequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:321:9: error: no member named ‘isless’ in the global namespace
using ::isless;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:322:9: error: no member named ‘islessequal’ in the global namespace
using ::islessequal;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:323:9: error: no member named ‘islessgreater’ in the global namespace
using ::islessgreater;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:324:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:325:9: error: no member named ‘isunordered’ in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:28: error: expected a qualified name after ‘typename’
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected ‘;’ at end of declaration
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:551:37: error: expected unqualified-id
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:39: error: use of undeclared identifier ‘is_floating_point’
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:57: error: ‘_A1’ does not refer to a value
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:561:17: note: declared here
template
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:563:63: error: definition or redeclaration of ‘value’ cannot name the global scope
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [file2ed201aa62.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
1:
2: // includes from the plugin
3: #include <R.h>
4: #include <Rdefines.h>
5: #include <R_ext/Error.h>
6:
7:
8: // user includes
9:
10:
11: // declarations
12: extern “C” {
13: SEXP file2ed201aa62( SEXP x, SEXP y) ;
14: }
15:
16: // definition
17:
18: SEXP file2ed201aa62( SEXP x, SEXP y ){
19:
20: return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
21:
22: Rf_warning(“your C++ program does not return anything”);
23: return R_NilValue ;
24: }
25:
26:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from file2ed201aa62.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:313:9: error: no member named ‘signbit’ in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:314:9: error: no member named ‘fpclassify’ in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cmath:315:9: error: no member named ‘isfinite’ in the global namespace; did you mean ‘finite’?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: ‘finite’ declared here
extern int finite(double)
^
In file included from file2ed201aa62.cpp:3:
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:50:
/Library/Developer/CommandLineTools/usr/include/c++/v


#16

Is there a .pkg at
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg
or perhaps with some minor difference in the numbers in the filename?


#17

Yes, it has exactly that name


#18

Yes, it’s there.


#19

OK, try double-clicking on that to install the C++ headers to /usr/include and then in

file.edit("~/.R/Makevars")

delete the part of CXX14FLAGS where it says -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include.


#20

It worked! Thank you so much!