diff --git a/lodepng_util.cpp b/lodepng_util.cpp
index 4b571bb..58ba81a 100644
--- a/lodepng_util.cpp
+++ b/lodepng_util.cpp
@@ -26,6 +26,7 @@ freely, subject to the following restrictions:
 #include "lodepng_util.h"
 #include <iostream>
 #include "math.h"
+#include <algorithm>
 
 namespace lodepng
 {
