Dealing with Catalina II

I believe these are the three that keep repeating throughout the messages, thanks!

/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:22:30: error: no template named 'conditional_t' in namespace 'std'; did you mean 'conditional'?
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
                        ~~~~~^~~~~~~~~~~~~
                             conditional
/usr/local/clang7/include/c++/v1/type_traits:424:33: note: 'conditional' declared here
    struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};


/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:22:63: error: no template named 'remove_reference_t' in namespace 'std'; did you mean 'remove_reference'?
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
                                                         ~~~~~^~~~~~~~~~~~~~~~~~
                                                              remove_reference
/usr/local/clang7/include/c++/v1/type_traits:1110:50: note: 'remove_reference' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference        {typedef _Tp type;};

/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:60:10: error: no template named 'enable_if_t' in namespace 'std'; did you mean 'enable_if'?
    std::enable_if_t<std::is_pointer<T>::value, reverse_return_t<T>>
    ~~~~~^~~~~~~~~~~
         enable_if
/usr/local/clang7/include/c++/v1/type_traits:435:63: note: 'enable_if' declared here
template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};

Yes, that is it. What is packageVersion("StanHeaders")?

StanHeaders version ‘2.21.0.1’

Does it work if you call in R

Sys.unsetenv("PKG_CXXFLAGS")

after calling library(rstan) but before calling sourceCpp?

2 Likes

Yes, that fixes it!

OK. I guess just go that way for now. We had to set that environmental variable to move StanHeaders forward on CRAN but can remove it in the future.

Good to know, many thanks

Hi Everyone!

I used the latest installer linked above, but that left me with a non-working setup for running stan models. The reasons seems to be that the tools leave you with a ~/.R/Makevars with this content:

# clang: start
CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

SHLIB_CXXLDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib
# clang: end

but for Stan we have to also modify the C++14 flags like this:

# clang: start
CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

CXX14FLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPF14LAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

SHLIB_CXXLDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib

SHLIB_CXX14LDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib
# clang: end

With the above changes for C++14 everything works now for me.

Tagging @mcol

… and for everyone who is blocked by Catalina not being allowed to install the .pkg file… a simple CTRL+right click on the file, then clicking “Open” will get the installer going (for me).

Did you want to tag somebody else? I’m not on Mac.

1 Like

ups… sorry… I meant @coatless

Thanks @torkar , this worked for me!

1 Like

works! Thanks so much!

1 Like

I had the same problem on macOS 10.15.4, and the solution worked perfectly. Many thanks!

@riko, note however that with R v4.0.0 nothing much is needed in the ~/.R/Makevars anymore (well, compiler settings perhaps, but that’s it). In mine I only have this now:

FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX14FLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function 

I´m using R v4.0.0 on macOS Catalina 10.15.2. and I´m still facing the same problem.

clang-7: error: no such file or directory: ‘/Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib’
make: *** [rstan.so] Error 1
ERROR: compilation failed for package ‘rstan’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan’
    Warning in install.packages :
    installation of package ‘rstan’ had non-zero exit status

The .R/Makevars file contains

`#clang: start

CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

SHLIB_CXXLDFLAGS+=-Wl,-rpath,{R_HOME}/lib {R_HOME}/lib/libc++abi.1.dylib
SHLIB_CXX14LDFLAGS+=-Wl,-rpath,{R_HOME}/lib {R_HOME}/lib/libc++abi.1.dylib

#clang: end`

. I also tried

but to no avail and showed error -
/usr/local/clang7/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found #include_next <stdlib.h>

Any pointers to rectify this problem ?

I think you’re not using the Xcode compiler? I don’t have a clang-7 on my OS X.

Typing this, g++ --version in the terminal gives this,


Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Yes,
Command g++ --version in terminal shows a similar output.
How can i fix this issue?

Please paste your output here. Saying “similar output” means that they are not the same and that gets me curious…

Apologies, its the exact same output

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

The above seems to be the problem. Have you removed all traces of the previous installation (clang7)? I don’t have that file on my laptop anymore…