diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index 0f966839cc9c9cfa670af2963d02f0f1eae83ddd..71e1a2850bac3d491d3b97878b22a9b340e1705a 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -2236,6 +2236,7 @@ ModelTree::compileDll(const string &basename, const string &static_or_dynamic, c
       else
         {
           // macOS
+          compiler = "/usr/local/bin/gcc-7";
           string archs = (mexext == "maci" ? "i386" : "x86_64");
           flags << " -fno-common -arch " << archs << " -mmacosx-version-min=10.7 -Wl,-twolevel_namespace -undefined error -bundle";
           libs += " -lm -lstdc++";