rugarch install on MacOS x

Hi everyone!
I'm trying to install the package, rugarch, for a class. I am using MacOS Mojave 10.14.6 (18G3020).
I am using RStudio:
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

I'm trying to figure out why it's not installing.
Most of the forums I searched on report the need for Xquartz, but I already have installed it.

Wondering what to try next...... Thanks for your help!

> install.packages('rugarch')
also installing the dependency ‘RcppArmadillo’

trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/src/contrib/RcppArmadillo_0.8.600.0.0.tar.gz'
Content type 'application/octet-stream' length 1356993 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/src/contrib/rugarch_1.4-0.tar.gz'
Content type 'application/octet-stream' length 2936961 bytes (2.8 MB)
==================================================
downloaded 2.8 MB

* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ accepts -g... yes
checking how to run the C++ preprocessor... clang++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... found
configure: WARNING: OpenMP unavailable and turned off.
checking LAPACK_LIBS... system LAPACK found
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
/usr/local/clang4/bin/clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/Rcpp/include" -DU_STATIC_IMPLEMENTATION -Wall -mtune=core2 -g -O2 -I/opt/X11/include  -I../inst/include  -fPIC  -DU_STATIC_IMPLEMENTATION -Wall -mtune=core2 -g -O2 -I/opt/X11/include -c RcppArmadillo.cpp -o RcppArmadillo.o
/bin/sh: /usr/local/clang4/bin/clang++: No such file or directory
make: *** [RcppArmadillo.o] Error 127
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/RcppArmadillo’
Warning in install.packages :
  installation of package ‘RcppArmadillo’ had non-zero exit status
ERROR: dependency ‘RcppArmadillo’ is not available for package ‘rugarch’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/rugarch’
Warning in install.packages :
  installation of package ‘rugarch’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/bm/wg7t4j8j3tz_88yfzyfdkkhm0000gn/T/Rtmp5GtJ3y/downloaded_packages’

I got past the cross compiling error by following Davis, an RStudio employee: Can't install most packages on Mac

1. `xcode-select --install`
2. Run  `installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /`  which has been related to a number of strange issues (including one with rcpp autocomplete and with xml2)

However, my error remains :frowning:

> install.packages('RcppArmadillo')
trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/src/contrib/RcppArmadillo_0.8.600.0.0.tar.gz'
Content type 'application/octet-stream' length 1356993 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ accepts -g... yes
checking how to run the C++ preprocessor... clang++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... not found
checking for clang compiler... found
checking for OpenMP compatible version of clang... found and suitable
checking LAPACK_LIBS... system LAPACK found
checking for OpenMP... found and suitable
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
/usr/local/clang4/bin/clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/Rcpp/include" -DU_STATIC_IMPLEMENTATION -Wall -mtune=core2 -g -O2 -I/opt/X11/include  -I../inst/include -fopenmp -fPIC  -DU_STATIC_IMPLEMENTATION -Wall -mtune=core2 -g -O2 -I/opt/X11/include -c RcppArmadillo.cpp -o RcppArmadillo.o
/bin/sh: /usr/local/clang4/bin/clang++: No such file or directory
make: *** [RcppArmadillo.o] Error 127
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/RcppArmadillo’
Warning in install.packages :
  installation of package ‘RcppArmadillo’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/bm/wg7t4j8j3tz_88yfzyfdkkhm0000gn/T/RtmpkTl7tz/downloaded_packages’ 

I have read and searched through
https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos-before-r-3.6.0/
and

Any help would be much appreciated! Thanks

Hi @hohaddict,
Your frustration is noted!

Your output says this directory can't be found:
/usr/local/clang4/bin/clang++

Have you checked that C++ is installed on your Mac machine?
See this link for testing that, and possible solutions:
https://superuser.com/questions/277298/how-to-test-if-gcc-is-installed

HTH

Hi Davo!
Appreciate the reply.

It's installed. Based on calling the gcc version in terminal:
gcc -v

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I'm considering this problem has to do with which clang I'm using and how it's setup???
I initially installed clang6. Couldn't install rugarch. So then I went through the posts I pasted previously, which recommended trying clang 4, so I also installed that.
The error indicates the output directory can't be found:
/usr/local/clang4/bin/clang++

I went and checked in Finder, and indeed there is no 'bin' folder in /usr/local/clang4
However, I did find it in /user/local/clang6. Full path to /bin/clang++.

Hey Davo!
Just seeing if you had any tips on my followup
thanks!

I also just tried downloading the binary version and not the source, but got the following error...:

install.packages("RcppArmadillo", type="binary)
Error in install.packages : type 'binary' is not supported on this platform

I guess I can try upgrading to Rv3.6.3???? I'm using 3.5.1 because of my class though and the professor said version newer than 3.5.1 require extra add-ons so I'm hesitant to change versions on my Mac[quote="hohaddict, post:6, topic:67892, full:true"]
Hey Davo!
Just seeing if you had any tips on my followup
thanks!
[/quote]

.....

Have you tried updating R?
Apparently the latest version doesn't require a custom compiler, so it should be simpler.

CRAN R 4.0.0 builds and higher no longer use any custom compilers and thus this directory is no longer relevant. We now use Apple Xcode 10.1 and GNU Fortran 8.2 from Releases · fxcoudert/gfortran-for-macOS · GitHub.

Hi Andres,

Thanks for the reply.
I will try downloading R-4.0.1.pkg
upgrade my Xquartz
and try running rugarch again
will let you know how it goes!

One clarification:
As I followed the links from the R-4.0.1.pkg, I was directed to download clang8

But the description of R-4.0.1.pkg states:
"this release uses Xcode 10.1 and GNU Fortran 8.2. If you wish to compile R packages from sources, you will need to download and GNU Fortran 8.2"

Which one should I install?

@andresrcs
The upgrade to the most recent version of R worked! Thanks for that suggestion.
I ended up downloading clang8, per the directions in the link.

The remaining question is still: Should I care about downloading GNU Fortran 8.2 in the future or does clang8 do the same thing?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.