I have mpi running on a cluster. It works fine for executables, as well as C programs; so I am pretty sure it works fine. However, when I am trying to install Rmpi, I get an error.
Architecture:
Centos 6.4
MPICH 3.0.3 (had the same problem with 1.4).
R 2.15
Rmpi 0.6-3
I tried different combinations. Specifically, tried to run install.packages() from inside R, and R CMD INSTALL from command line. I tried sudo, su -, and even install into non-privileged "private" directory (in case setting LD_LIBRARY_PATH screws things up). So, here is an example of what I ran:
export LD_LIBRARY_PATH=/opt/tmp/shared/mpich2-install/lib/
install.packages("Rmpi", configure.args = c("--with-Rmpi-include=/opt/tmp/shared/mpich2-install/include/", "--with-Rmpi-libpath=/opt/tmp/shared/mpich2-install/lib/", "--with-Rmpi-type=OPENMPI", "--with-mpi=/opt/tmp/shared/mpich2-install/"))
In every event I get consistent error:
gcc -m64 -std=gnu99 -shared -L/usr/local/lib64 -o Rmpi.so RegQuery.o Rmpi.o conversion.o internal.o -L/opt/tmp/shared/mpich2-install/lib/ -lmpi -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lmpi
collect2: ld returned 1 exit status
Note, that if I put mpi-type as MPICH (instead of OPENMPI) I get an error about bad format.
I ran out of ideas... There is a similar post, but my problem seems different. Thanks.
Apparently, this is a known incompatibility between MPICH and Rmpi. I installed Open MPI and everything worked just fine. Maybe, it will help somebody as well...
Related
I'm trying to use packages that require Rcpp in R on my M1 Mac, which I was never able to get up and running after purchasing this computer. I updated it to Monterey in the hope that this would fix some installation issues but it hasn't. I tried running the Rcpp check from this page but I get the following error:
> Rcpp::sourceCpp("~/github/helloworld.cpp")
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0'
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_4.so] Error 1
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I"/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/RcppArmadillo/include" -I"/Users/afredston/github" -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c helloworld.cpp -o helloworld.o
clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o sourceCpp_4.so helloworld.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in Rcpp::sourceCpp("~/github/helloworld.cpp") :
Error 1 occurred building shared library.
I get that it can't "find" gfortran. I installed this release of gfortran for Monterey. When I type which gfortran into Terminal, it returns /opt/homebrew/bin/gfortran. (Maybe this version of gfortran requires Xcode tools that are too new—it says something about 13.2 and when I run clang --version it says 13.0—but I don't see another release of gfortran for Monterey?)
I also appended /opt/homebrew/bin: to PATH in R so it looks like this now:
> Sys.getenv("PATH")
[1] "/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/Applications/RStudio.app/Contents/MacOS/postback"
Other things I checked:
Xcode command line tools is installed (which clang returns /usr/bin/clang).
Files ~/.R/Makevars and ~/.Renviron don't exist.
Here's my session info:
R version 4.1.1 (2021-08-10)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.1 tools_4.1.1 RcppArmadillo_0.10.7.5.0
[4] Rcpp_1.0.7
Background
Currently (2023-02-20), CRAN builds R 4.2 binaries for Apple silicon using Apple clang from Command Line Tools for Xcode 13.1 and using an experimental fork of GNU Fortran 12.
If you obtain R from CRAN (i.e., here), then you need to replicate CRAN's compiler setup on your system before building R packages that contain C/C++/Fortran code from their sources (and before using Rcpp, etc.). This requirement ensures that your package builds are compatible with R itself.
A further complication is the fact that Apple clang doesn't support OpenMP, so you need to do even more work to compile programs that make use of multithreading. You could circumvent the issue by building R itself and all R packages from sources with LLVM clang, which does support OpenMP, but that approach is onerous and "for experts only".
There is another approach that has been tested by a few people, including Simon Urbanek, the maintainer of R for macOS. It is experimental and also "for experts only", but it works on my machine and is much simpler than learning to build R yourself.
Instructions for obtaining a working toolchain
Warning: These come with no warranty and could break at any time. Some level of familiarity with C/C++/Fortran program compilation, Makefile syntax, and Unix shells is assumed. Everyone is encouraged to consult official documentation, which is more likely to be maintained than answers on SO. As usual, sudo at your own risk.
I will try to address compilers and OpenMP support at the same time. I am going to assume that you are starting from nothing. Feel free to skip steps you've already taken, though you might find a fresh start helpful.
I've tested these instructions on a machine running Big Sur, and at least one person has tested them on a machine running Monterey. I would be glad to hear from others.
Download an R 4.2 binary from CRAN here and install. Be sure to select the binary built for Apple silicon.
Run
$ sudo xcode-select --install
in Terminal to install the latest release version of Apple's Command Line Tools for Xcode, which includes Apple clang. You can obtain earlier versions from your browser here. However, the version that you install should not be older than the one that CRAN used to build your R binary.
Download the gfortran binary recommended here and install by unpacking to root:
$ curl -LO https://mac.r-project.org/tools/gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz
$ sudo tar xvf gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz -C /
$ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
The last command updates a symlink inside of the gfortran installation so that it points to the SDK inside of your Command Line Tools installation.
Download an OpenMP runtime suitable for your Apple clang version here and install by unpacking to root. You can query your Apple clang version with clang --version. For example, I have version 1300.0.29.3, so I did:
$ curl -LO https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
$ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
After unpacking, you should find these files on your system:
/usr/local/lib/libomp.dylib
/usr/local/include/ompt.h
/usr/local/include/omp.h
/usr/local/include/omp-tools.h
Add the following lines to $(HOME)/.R/Makevars, creating the file if necessary.
CPPFLAGS += -I/usr/local/include -Xclang -fopenmp
LDFLAGS += -L/usr/local/lib -lomp
Run R and test that you can compile a program with OpenMP support. For example:
if (!requireNamespace("RcppArmadillo", quietly = TRUE))
install.packages("RcppArmadillo")
Rcpp::sourceCpp(code = '
#include <RcppArmadillo.h>
#ifdef _OPENMP
# include <omp.h>
#endif
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
void omp_test()
{
#ifdef _OPENMP
Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
#else
Rprintf("OpenMP not supported\\n");
#endif
}
')
omp_test()
OpenMP threads available: 8
If the C++ code fails to compile, or if it compiles without error but you get linker warnings or you find that OpenMP is not supported, then one of us has probably made a mistake. Please report any issues.
References
Everything is a bit scattered:
R Installation and Administration manual [link]
R for macOS Developers page [link]
I resolved this issue by adding a path to the homebrew installation of gfortran to my ~/.R/Makevars following these instructions: https://pat-s.me/transitioning-from-x86-to-arm64-on-macos-experiences-of-an-r-user/#gfortran
I just avoided the issue until MacOS had things working more smoothly. so I either Windows Developer Virtual Machine (VM) or run my code development in another environment. I'm not too impressed with the updated and "faster" chipset, but that it doesn't work with much. Slow to implement and work-a-rounds often are a must.
Tested the following process for making multithread data.table work in a M2 MacBook Pro (macOS Monterey)
Steps are mostly the same with this answer by the user inferator.
Download and install R from CRAN
Download and install RStudio with developer tools
Run the following commands in terminal to install OpenMP
curl -O https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
sudo tar fvxz openmp-12.0.1-darwin20-Release.tar.gz -C /
Add compiler flags to connect clan w/ OpenMP. In terminal, write the following:
cd ~
mkdir .R
nano .R/Makevars
Inside the opened Makevars file paste the following lines. Once finished, hit command+O and then Enter to save. Do a command+X to close the editor.
CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp
Download and run the installer for gfortran by downloading gfortran-ARM-12.1-Monterey.dmg from the respective GitHub repo
This concludes the steps regarding enabling OpenMP and (hopefully) Rcpp in R under a M2 chip system.
Now, for testing that everything works with data.table I did the following
Open RStudio and run
install.packages("data.table", type = "source")
If everything is done correctly, the package should compile without any errors and return the following when running getDTthreads(verbose = TRUE):
OpenMP version (_OPENMP) 201811
omp_get_num_procs() 8
R_DATATABLE_NUM_PROCS_PERCENT unset (default 50)
R_DATATABLE_NUM_THREADS unset
R_DATATABLE_THROTTLE unset (default 1024)
omp_get_thread_limit() 2147483647
omp_get_max_threads() 8
OMP_THREAD_LIMIT unset
OMP_NUM_THREADS unset
RestoreAfterFork true
data.table is using 4 threads with throttle==1024. See ?setDTthreads.
[1] 4
RcppArmadillo 0.8.400.0.0 works just fine on my computer, both from sourceCpp and cxxfunction. Now I want to upgrade to 0.8.500.0, which requires compilation from source. Then I got the error
ccache /usr/local/clang6/bin/clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -I/Applications/CPLEX_Studio128/cplex/include -I/Applications/CPLEX_Studio128/concert/include -DIL_STD -fPIC -Wall -g -O2 -c RcppArmadillo.cpp -o RcppArmadillo.o
RcppArmadillo.cpp:22:10: fatal error: 'RcppArmadillo.h' file not found
#include <RcppArmadillo.h>
^~~~~~~~~~~~~~~~~
1 error generated.
I got this error whether I ran install.packages("RcppArmadillo") in RStudio or in R console outside RStudio. My compiler is clang4, and I have no problem installing RcppParallel or compiling my own Rcpp code that uses RcppArmadillo and RcppParallel. R version: 3.5.0, MacOS High Sierra.
Edit: I looked at https://github.com/RcppCore/RcppArmadillo/issues/143, which is very relevant. I did install clang6 and gfortran 6.1, both downloaded from the CRAN website. I also changed the .R/Makevars file to reflect the changes to clang6. I have also installed ccache as suggested, to make compilation faster. Here's my Makevars:
F77 = /usr/local/gfortran/bin/gfortran
FC = $F77
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CC=ccache /usr/local/clang6/bin/clang
SHLIB_CXXLD=ccache /usr/local/clang6/bin/clang++
CXX= ccache /usr/local/clang6/bin/clang++ -Wall
CXX1X= ccache /usr/local/clang6/bin/clang++
CXX98= ccache /usr/local/clang6/bin/clang++
CXX11= ccache /usr/local/clang6/bin/clang++
CXX14= ccache /usr/local/clang6/bin/clang++
CXX17= ccache /usr/local/clang6/bin/clang++
LDFLAGS=-L/usr/local/clang6/lib
From the outputs in the R console when I was installing the package (added to the error message above), I can tell that clang6 was used for compilation. I also found the downloaded RcppArmadillo tarball, unpacked it, and ran ./configure from the command line. Nothing seemed wrong there; no config.log file was generated. This doesn't seem to be a configuration problem. Then I still got the exact same error when trying to install the package in R, after configuration, in libs. I also didn't get any message about -fopenmp. It seems that my problem is a bit different from that in the GitHub ticket.
R 3.5.x requires clang6 and adding clang6 to your system PATH variable.
Steps:
x Download and install the clang-6.0.0.pkg official package from CRAN.
x Delete your ~/.R/Makevars as it is likely set to use clang4. To do this, open Terminal and type:
sudo rm ~/.R/Makevars
x Then add to your ~/.bash_profile the following:
if [ -d "/usr/local/clang6/bin" ] ; then
export PATH="/usr/local/clang6/bin:$PATH"
fi
Note: If you are using a shell other than bash you will need to add the above into the appropriate file, e.g. for zsh add to ~/.zshrc, as this was not implemented in the official installer.
I should have a few cycles to finish writing a new unofficial Rtools installer a bit later. See: https://github.com/coatless/r-macos-rtools/issues/7
Note: Alternatively, you can remove the paths individual with
sudo vi ~/.R/Makevars
Pressing I to enter insert mode, deleting lines with clang4 in the path, and then pressing ESC + :wq to write changes to file.
Never mind, this problem went away with version 0.8.600. Later, this problem appeared again when I upgraded to RcppArmadillo 0.9.100.5.0. Somehow I only got this error when building from source; I downloaded the binary manually from the CRAN website, and used R CMD INSTALL to install the prebuilt version, and it worked; somehow R doesn't seem to know that there is a binary available for the newest version.
I did install clang6 and modified .R/Makevars to use clang6, but the same problem persisted; probably something else caused the problem.
I have seen a number of different people post this problem (example: Tried to guess R's HOME but no R command in the PATH. OsX 10.6 and Installing rpy2 on Mac OSX 10.8.5), but I have yet to find a viable solution.
I have ensured that I have Python-2.7 installed in my terminal, and since I had recently upgraded by RStudio, I thought that my R was also updated. But everytime I tried to run either:
pip install rpy2
or
easy_install rpy2
I kept getting the same error of Error: Tried to guess R's HOME but no command 'R' in the PATH.
After some googling, I decided to try to download the latest version of R (v 3.4.1), even though I'm very certain it was already updated to begin with. But now I get the following behemoth of an error (I should note that I have condensed it):
In file included from ./rpy/rinterface/_rinterface.c:122:
./rpy/rinterface/sequence.c:2173:1: warning: unused function 'ComplexVectorSexp_AsSexp' [-Wunused-function]
ComplexVectorSexp_AsSexp(PyObject *pyfloat) {
^
11 warnings generated.
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.12-intel-2.7/./rpy/rinterface/_rinterface.o -L/usr/local/lib -Lbuild/temp.macosx-10.12-intel-2.7 -L/usr/local/lib -lpcre -llzma -lbz2 -lz -licucore -lm -liconv -lr_utils -o build/lib.macosx-10.12-intel-2.7/rpy2/rinterface/_rinterface.so -fopenmp -F/Library/Frameworks/R.framework/.. -framework R
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-zT8DaX/rpy2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-bDnbE5-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-zT8DaX/rpy2/
So now I have a completely different error occurring. I thought that upgrading my R would automatically add it to my environmental variable PATH, but now I'm really at a loss at how to deal with this. I have tried to google this new error but I can't seem to find any solutions that are geared towards installing Rpy2 on a Mac OSX with Python-2.7 and R-3.4. Can anybody offer any kind of advice?
ADDENDUM
I have now tried a variety of other approaches, including downloading XCODE, and updating my GCC compiler, (one such approach is delineated in http://cs.millersville.edu/~gzoppetti/InstallingGccMac.html), and I have also tried to reinstall GCC with the command brew reinstall gcc --without-multilib. I have also edited my PATH environmental variables to include R, CC, and have still had no luck.
I have now figured out that rpy2 installation is contingent upon the right kind of compiler being used. The default compiler for Apple is clang, which does not support rpy2's set up process. So, after acquiring the gcc compiler via homebrew, you can then run brew ls gcc to see the file paths of what gcc compilers are present on your computer. I then ran the following commands in the terminal to change the default compiler from clang to the file path gcc-7, then set the proper flags (which I deduced from reading the error messages yielded by the compiler before), and then install rpy2.
export CC=/usr/local/Cellar/gcc/7.2.0/bin/x86_64-apple-darwin16.7.0-gcc-7
export CFLAGS="-W"
pip install rpy2==2.8.6
I should note that I installed rpy2 version 2.8.6 since my scripts are in Python 2.7, and rpy2 2.9.0 is only compatible with Python 3.x. Furthermore, I am aware that this answer might not adequately describe the problem for everyone, so I encourage other users to expand and/or correct this solution.
The error about "no R in the PATH" is exactly about what it says. To reproduce, open a terminal and enter "R": there should not be any such command found. The solution is to have R findable in the PATH.
Now starting with R-3.4 the tools needed to compile R and and R extensions in C have changed, and the requirements are less standard than one might hope for. This can be debated to be an issue with R and OS X, and there is an open issue in the rpy2 tracker about it.
edit: Note that the issue was resolved and a precompiled binary wheel for rpy2-2.9.3 is now available on pypi.
It's possible to do the GCC switch with a single env command:
env CC=/usr/local/Cellar/gcc/7.2.0/bin/gcc-7 pip install rpy2
The reason clang doesn't work with RPy2 is because clang 4.0.0 doesn't include the -fopenmp flag, which is used by R. There's an ongoing open problem thread on the RPy2 Bitbucket about it.
I'm trying to run a make file to install qserver on my OSX machine.
The make file gives me an error when I try to run. see code below:
make
/Library/Frameworks/R.framework/Resources/bin/R CMD gcc -g -O -fpic -m64 -shared -D KXVER=3 -I. -I/Library/Frameworks/R.framework/Resources/share/include base.c c.o -lpthread -L/Library/Frameworks/R.framework/Resources/share/lib -lR -o qserver.so
/Library/Frameworks/R.framework/Resources/bin/R: /Library/Frameworks/R.framework/Resources/bin/R: cannot execute binary file
make: *** [all] Error 126
Hoping someone can give me a pointer here on how to fix it.
Do you have the right version of gcc? I build with gcc-4.8 and have no issues. I recall a thread on the kdb list that mentioned the build required some features available only in later gcc versions. Give that a try.
[EDIT]
Nevermind, just saw that the error says the R binary was not found. Edit the make file to use the appropriate path for your R installation. If you don't have R installed, I suggest installing with homebrew:
brew tap homebrew/science
brew install r
After that you can replace the path in the Makefile as appropriate. I personally changed the Makefile to use $(shell R RHOME) to find the R home path, rather than assume a specific location.
JPC was partially right about gcc.
My system had two different versions of gcc loaded and the default was the standard one. I changed the makefile to run 'gcc-4.8'.
Once I finished that I got a new error: the make file couldn't locate my 'R.h' file...so i just had to reference where my r h-files were located....once I did that the make problem executed.
I'm using the OS X devel version of R
R Under development (unstable) (2014-05-27 r65787)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
with GNU Fortran (GCC) 4.2.3 (from Simon's site) and version 5.1.1 of Xcode's command line tools.
When building from source, I get errors like:
gfortran-4.8 -fPIC -g -O2 -c altmov.f -o altmov.o
make: gfortran-4.8: No such file or directory
I'm not sure what to do here. I could create an alias to the version I have but I'm not sure if it really needs 4.8 or not.
Thanks,
Max
Type these two lines in your terminal, direct quote:
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
sudo tar fvxj gfortran-4.8.2-darwin13.tar.bz2 -C /
It will download you the gfortran for Mavericks (which is missing in your system at the moment) and will install it in your system. At least, this solved the same problem for me
(I'm running late 2011 MacPro, Mavericks).
Edit: I now think this is best accomplished using Homebrew:
brew reinstall gcc48 --with-fortran
While I think the following procedure will work, it is not as clean. However, I still recommend configuring ~/.R/Makevars as described below.
To build on the answer by #TheBigMike, I used the following procedure to install gfortran-4.8 alongside homebrew, and then configured R to select this fortran compiler.
First, download and unpack gfortran 4.8:
su admin
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
mkdir /tmp/gfortran
tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /tmp/gfortran
Delete the gfortran file alias that interferes with homebrew:
rm /tmp/gfortran/usr/local/bin/gfortran
Install gfortran 4.8
cp -r /tmp/gfortran/usr/local/ /usr/local
To tell R to use gfortran 4.8, create a file called ~/.R/Makevars:
mkdir -p ~/.R
touch ~/.R/Makevars
Put the following into ~/.R/Makevars:
FLIBS=""
F77="gfortran-4.8"
FC="gfortran-4.8"
Now restart R. Once R has been restarted, any packages that depend upon fortran 4.8 should now work. homebrew should be undisturbed.
I encountered the same problem, albeit on R Studio.
The following worked for me, although, I had to reinstall all my R packages after (note: the re-installations took awhile and look like quite a bit was going on, unsure if these were the appropriate steps, use at own risk):
Download latest R Studio version and then following in terminal:
brew install gcc
brew update && brew reinstall r
brew link --overwrite r
This is explained nicely in Rcpp FAQ, section 2.16. Basically you need to install gfortran (homebrew install gcc or the other way) and then modify Makeconf to point FLIBS to the relevant fortran libraries.
These were the steps which worked for me:
Install gcc48 via homebrew
Make sure that gfortran and gfortran-4.8 point to the newly installed versions.
Comment the FLIBS variable in /Library/Frameworks/R.framework/Resources/etc/Makeconf.
The step 3 was the most important one, because it is designed to work with the gfortran which is installed in the way #TheBigMike suggested, i.e. by downloading and extracting the archive gfortran-4.8.2-darwin13.tar.bz2.
The following worked for me on OSX High Sierra and RStudio 1.1.423:
Install gcc/gfortran via Homebrew: brew install gcc
Edit /Library/Frameworks/R.framework/Resources/etc/Makeconf and replace all instances of gfortran-4.8 with gfortran
Also replace FLIBS = -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 with FLIBS = -L/usr/local/lib/gcc/7/ -lgfortran -lquadmath -lm.
Reattempt installing the package.
Install gcc/gfortran via Homebrew: brew install gcc
Make sure you replace it is not done automatically: /Library/Frameworks/R.framework/Resources/etc/Makeconf and replace all instances of gfortran-4.8(or any number) with gfortran
Replace FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm to
FLIBS = -L/usr/local/lib/gcc/7/ -lgfortran -lquadmath -lm
Reinstall the package for me was robustbase that was required by fpc library
Got the same issue and found a statement in the R cran site (https://cran.ism.ac.jp/) In the latest OSX such as High Sierra, some necessary libs are not included and these have to be installed. The page kindly explains this, quoting
Important: this release uses Clang 6.0.0 and GNU Fortran 6.1, neither
of which is supplied by Apple. If you wish to compile R packages from
sources, you will need to download and install those tools - see the
tools directory.
I resolved the issues (missing gfortran etc.) with applying the following two packages, here.
clang-6.0.0.pkg (OS X 10.11+, signed, 64-bit)
MD5-hash: c29700c4e7b2914073ef7e741eb105bc
(ca. 418Mb)
gfortran-6.1.pkg (OS X 10.11+, signed, 64-bit)
MD5-hash: 201026216e8b373d9cd2efc0cc474bb8
(ca. 73Mb)
This answer by thebigmike suggests:
Type these two lines in your terminal, direct quote:
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
sudo tar fvxj gfortran-4.8.2-darwin13.tar.bz2 -C /
but
curl -OL http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
Solves the problem for me!
Updated version of RStudio (Version 0.98.1091) seems to fix this.
Make sure R is updated to version >= 4.0 (for previous versions this might help: https://cran.ism.ac.jp/bin/macosx/tools/)
Download and install the GNU fortran compiler found here: https://mac.r-project.org/tools/
Make sure you add /usr/local/gfortran/bin to your PATH in order to use this compiler. This can be done, e.g. by
export PATH=$PATH:/usr/local/gfortran/bin
If you are having trouble installing software that depends on FORTRAN on Max OS 10.15 or later. The best solution is to update R to at least version 4.0.0
Installing gcc via homebrew give me gfortran:
brew install gcc
Then:
$which gfortran
/usr/local/bin/gfortran