0

I'm having problems at installing the package ape from CRAN on macOS by using the following code line: install.packages("ape").

I get the following outputs:

ld: warning: directory not found for option ' L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2' ld: library not found for -lgfortran clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've tried to troubleshoot the problem by installing Xcode using the following code in the terminal: xcode-select--install. It didn't help tough.

Ema
  • 23
  • 3
  • That is a bit surprising in that the default for R running under MacOS is to attempt to install binaries, and binary installation should not be giving that error. Are you sure you are not attempting to install a package from source that requires compilation? For that purpose, recent versions of R need Xcode from Apple .... AND the proper versions of clang and gfortran from CRAN installed: https://cran.r-project.org/bin/macosx/tools/ – IRTFM Jun 08 '19 at 16:40
  • Maybe this post will help you : https://stackoverflow.com/questions/35999874/mac-os-x-r-error-ld-warning-directory-not-found-for-option – Rémi Coulaud Jun 08 '19 at 16:42

1 Answers1

5

An easy solution is to install the binary version if available; generally for new users this is the best strategy. I guess you have

> getOption("pkgType")
[1] "source"

and you would like to instead use

options(pkgType = "mac.binary.el-capitan")

See ?options for some more detail; see ?.Rprofile for setting this option on startup.

Martin Morgan
  • 45,935
  • 7
  • 84
  • 112