In Mac OS I was getting an annoying warning when compiling Cpp code via Rcpp in R:

ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/version_number'

Adding a file called Makevars in ~/.R defining FLIBS to the actual location of gfortran in my machine fixed the problem. In my case, Makevars only contains the following line:

FLIBS=-L/usr/local/gfortran/lib

That’s it.