diff --git a/import/simplex/include/NMObjective.h b/import/simplex/include/NMObjective.h
index 223baf4..5d29e75 100644
--- a/import/simplex/include/NMObjective.h
+++ b/import/simplex/include/NMObjective.h
@@ -6,7 +6,13 @@
 #if !defined _userfile_
 #define _userfile_
 
+#ifdef __APPLE__
+// Use stdlib.h on macOS
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
+
 #include <vector>
 
 double getInitialStep();
@@ -21,18 +27,18 @@ extern char Fname[120];
 
 /* Initial trial step length, reflecting the refinement of the search lattice
  */
-#define initialStepLength 2.0 
+#define initialStepLength 2.0
 /*getInitialStep()*/
 
-/*  The search will halt if the trial step length is less than 
- *  or equal to the stoppingStepLength after a reduction of the 
+/*  The search will halt if the trial step length is less than
+ *  or equal to the stoppingStepLength after a reduction of the
  *  trial step length.
- */ 
+ */
 //#define stoppingStepLength tolerance
 
 /*  The maxCalls variable is not a hard limit on the number of function
  *  evaluations that may be performed by the search.  The search should
- *  always halt at a point from which none of the trial steps can find 
+ *  always halt at a point from which none of the trial steps can find
  *  improvement to be consistent with the formal theory regarding pattern
  *  searches.
  */
