0

EDIT: My OS is 10.15.4 and R is 4.0.0 and Xcode 11.4.1

I tried to install an archived package "OC" (Optimal Classification). I downloaded the file from here (oc_1.01.tar.gz) first and store it on my desktop. I have tried to install this through install.packages("oc_1.01.tar.gz", repo=NULL, type="source") or install_version("oc", version = "1.01", repos = "https://cran.r-project.org/") and it always failed with warnings as:

ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [oc.so] Error 1
ERROR: compilation failed for package ‘oc’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/oc’
Error: Failed to install 'unknown package' from URL:
  (converted from warning) installation of package ‘/var/folders/yv/gzy_ljk971d4jnlntnfvht_40000gn/T//Rtmpr8pJmf/remotes1e1745dfa9dc/oc’ had non-zero exit status

I have tried several solutions similar to this to download gcc or gcc@8 through Homebrew and made changes on the file Makeconf. However, as long as I made changes (even I restored the original codes), installation still fails and returns warnings as:

R clang: error: no such file or directory: 'SHLIB_LIBADD'
R clang: error: no such file or directory: '='

If I changed CC, CXX (including all CXX related such as CXX17), and FLIBS to gcc-8 or gcc-9, the returned warnings become:

R gcc-8: error: no such file or directory: 'SHLIB_LIBADD'
R gcc-8: error: no such file or directory: '='

I appreciate any help.

tzu
  • 183
  • 1
  • 9
  • I had no problem compiling version 1.01 from source with your `devtools::install_version` call on macOS 10.14.6. What version of macOS are you using? Have you already [installed the SDK headers](https://donatstudios.com/MojaveMissingHeaderFiles)? If so, please provide the contents of `~/.R/Makevars`. – Ian Campbell May 12 '20 at 18:55
  • @IanCampbell, thanks for your reply. My OS is 10.15.4 and R is 4.0.0. I am uninstalling and re-installing Command Line Tools as the instructions in the comments. It turns out I do not have the folder `Packages` so I keep getting errors. Also, I have tried to find out `~/.R/Makevars` but I cannot find it. – tzu May 12 '20 at 20:03
  • If re-installing command line tools doesn't work for you, try [this answer](https://stackoverflow.com/a/58349403/13095326). And if that doesn't work, check out [this blog post](https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/). – Ian Campbell May 12 '20 at 20:10
  • @IanCampbell, I uninstall Xcode, R, and Homebrew first, and them re-install Xcode and follow [your first link](https://stackoverflow.com/questions/58278260/cant-compile-a-c-program-on-a-mac-after-upgrading-to-catalina-10-15/58349403#58349403). It looks like the SDK headers were installed. However, while I install `devtools`, there are several warnings. When I tried to install `OC`, it still failed and returned many warnings and then says `make: gfortran: No such file or directory`. – tzu May 12 '20 at 21:17
  • @IanCampbell, regardless of those warnings, I finally installed `OC` on my laptop. After the actions in the previous comment, I downloaded gfortran-8.2-Mojave.dmg from [here](https://mac.r-project.org/tools/) and installed it, and then execute `export PATH=$PATH:/usr/local/gfortran/bin` to add `/usr/local/gfortran/bin` to my PATH. It still returns many warnings but it is installed now. – tzu May 12 '20 at 21:29

0 Answers0