How about doing the above using Xcode’s clang++ and headers? You probably need to comment out everything in ~/.R/Makevars .
clang++