I had a similar problem trying to install mvtnorm in R on Ubuntu. I was getting the error:
gcc: error: unrecognized command line option "-fstack-protector-strong"
I looked into which version of gcc was being used by default
which gcc
/home/ralien/anaconda3/bin/gcc
It turns out that, for some reason, Anaconda uses a gcc, g++, and gfortran compiler that is really old: version 4.8.5. This version doesn't seem to support the -fstack-protector-strong argument.
I checked the gcc, g++, and gfortran version in /usr/bin and saw that my system compilers were much newer, 5.4 or so. The trick is to force R to use the new compilers by creating
~/.R/Makevars
and changing the path for ALL compilers to the system version. So the Makevars file would contain the entries:
CC=/usr/bin/gcc
CXX=/usr/bin/g++
FC=/usr/bin/gfortran
F77=/usr/bin/gfortran
You can then use R CMD INSTALL to compile the package with the new version of gcc, g++, and gfortran.
Or at least this worked for me.