R | Issue Comes up with MetaboAnalystR Installation on Mac

2023/03/10 16:13 PM posted in  Coding Notes   comments
Tags:  #R

https://stackoverflow.com/questions/6302209/building-r-package-and-error-ld-cannot-find-lgfortran

ld: library not found for -lgfortran

Reason Fortran Version is not Compatible with gcc and g++

Solution

  1. Install Homebrew and run:
brew install gcc
  1. Check the gcc version under /usr/local/Cellar/gcc/
  2. Create a file ~/.R/Makevars with the contents (being mindful that this corresponded to gcc version 9.1.0):
VER=-12
CC=gcc$(VER)
CXX=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/12.2.0/lib/gcc/12