-diff -rupN QPBO-v1.3.src/QPBO.cpp QPBO-v1.3.src-patched/QPBO.cpp
---- QPBO-v1.3.src/QPBO.cpp  2010-01-25 10:38:59.000000000 -0500
-+++ QPBO-v1.3.src-patched/QPBO.cpp  2016-07-25 14:35:33.253091828 -0400
+diff -rupNw QPBO-v1.3.src/block.h QPBO-v1.3.src-patched/block.h
+--- QPBO-v1.3.src/block.h	2010-01-25 10:39:21.000000000 -0500
++++ QPBO-v1.3.src-patched/block.h	2017-09-06 15:02:16.638704004 -0400
+@@ -87,8 +87,8 @@
+ 	deallocated only when the destructor is called.
+ */
+ 
+-#ifndef __BLOCK_H__
+-#define __BLOCK_H__
++#ifndef __QPBO_BLOCK_H__
++#define __QPBO_BLOCK_H__
+ 
+ #include <stdlib.h>
+ 
+@@ -96,6 +96,9 @@
+ /***********************************************************************/
+ /***********************************************************************/
+ 
++namespace kolmogorov{
++namespace qpbo{
++
+ template <class Type> class Block
+ {
+ public:
+@@ -121,7 +124,7 @@ public:
+ 			else
+ 			{
+ 				block *next = (block *) new char [sizeof(block) + (block_size-1)*sizeof(Type)];
+-				if (!next) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
++               if (!next) { if (error_function) (*error_function)((char*)("Not enough memory!")); exit(1); }
+ 				if (last) last -> next = next;
+ 				else first = next;
+ 				last = next;
+@@ -220,7 +223,7 @@ public:
+ 		{
+ 			block *next = first;
+ 			first = (block *) new char [sizeof(block) + (block_size-1)*sizeof(block_item)];
+-			if (!first) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
++           if (!first) { if (error_function) (*error_function)((char*)("Not enough memory!")); exit(1); }
+ 			first_free = & (first -> data[0] );
+ 			for (item=first_free; item<first_free+block_size-1; item++)
+ 				item -> next_free = item + 1;
+@@ -263,6 +266,8 @@ private:
+ 	void	(*error_function)(char *);
+ };
+ 
++} //namespace qpbo
++} // namespace kolmogorov
+ 
+ #endif
+ 
+diff -rupNw QPBO-v1.3.src/instances.inc QPBO-v1.3.src-patched/instances.inc
+--- QPBO-v1.3.src/instances.inc	2010-01-25 10:38:59.000000000 -0500
++++ QPBO-v1.3.src-patched/instances.inc	2017-08-08 21:11:17.758558000 -0400
+@@ -1,34 +1,46 @@
+ #include "QPBO.h"
+ 
++#include <cinttypes>
++
+ #ifdef _MSC_VER
+ #pragma warning(disable: 4661)
+ #endif
+ 
+ // Instantiations
+-
+-template class QPBO<int>;
+-template class QPBO<float>;
+-template class QPBO<double>;
++namespace kolmogorov{
++namespace qpbo{
+ 
+ template <> 
+ 	inline void QPBO<int>::get_type_information(char*& type_name, char*& type_format)
+ {
+-	type_name = "int";
+-	type_format = "d";
++   type_name = (char*)("int");
++   type_format = (char*)("d");
++}
++
++template <> 
++	inline void QPBO<int64_t>::get_type_information(char*& type_name, char*& type_format)
++{
++   type_name = (char*)("int64_t");
++   type_format = (char*)(PRId64);
+ }
+ 
+ template <> 
+ 	inline void QPBO<float>::get_type_information(char*& type_name, char*& type_format)
+ {
+-	type_name = "float";
+-	type_format = "f";
++   type_name = (char*)("float");
++   type_format = (char*)("f");
+ }
+ 
+ template <> 
+ 	inline void QPBO<double>::get_type_information(char*& type_name, char*& type_format)
+ {
+-	type_name = "double";
+-	type_format = "Lf";
++   type_name = (char*)("double");
++   type_format = (char*)("Lf");
+ }
+ 
++template class QPBO<int>;
++template class QPBO<int64_t>;
++template class QPBO<float>;
++template class QPBO<double>;
+ 
++}}
+diff -rupNw QPBO-v1.3.src/QPBO.cpp QPBO-v1.3.src-patched/QPBO.cpp
+--- QPBO-v1.3.src/QPBO.cpp	2010-01-25 10:38:59.000000000 -0500
++++ QPBO-v1.3.src-patched/QPBO.cpp	2017-09-06 15:02:16.638704004 -0400
 @@ -4,8 +4,10 @@
  #include <stdio.h>
  #include <stdlib.h>

 // REAL: can be int, float, double.
 // Current instantiations are in instances.inc
@@ -263,7 +262,7 @@ public:
    //
    //         A. Billionnet and B. Jaumard. 
    //         A decomposition method for minimizing quadratic pseudoboolean functions. 
-   //         Operation Research Letters, 8:161163, 1989. 
+   //         Operation Research Letters, 8:161�163, 1989.   
    //
    //     For a review see also 
    //
@@ -811,5 +810,5 @@ template <typename REAL>
 */
 #define QPBO_MAXFLOW_TERMINAL ( (Arc *) 1 )        /* to terminal */
 #define QPBO_MAXFLOW_ORPHAN   ( (Arc *) 2 )        /* orphan */
-
+}}
 #endif
diff -rupN QPBO-v1.3.src/QPBO_maxflow.cpp QPBO-v1.3.src-patched/QPBO_maxflow.cpp
--- QPBO-v1.3.src/QPBO_maxflow.cpp  2010-01-25 10:38:59.000000000 -0500
+++ QPBO-v1.3.src-patched/QPBO_maxflow.cpp  2016-07-25 14:35:33.253091828 -0400
@@ -2,9 +2,10 @@
 
 

+namespace qpbo{
 
 template <typename REAL> 
 	QPBO<REAL>::QPBO(int node_num_max, int edge_num_max, void (*err_function)(char *))
@@ -24,7 +26,7 @@ template <typename REAL>
 
 	nodes[0] = (Node*) malloc(2*node_num_max*sizeof(Node));
 	arcs[0] = (Arc*) malloc(4*edge_num_max*sizeof(Arc));
-	if (!nodes[0] || !arcs[0]) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
+   if (!nodes[0] || !arcs[0]) { if (error_function) (*error_function)((char*)("Not enough memory!")); exit(1); }
 
 	node_last[0] = nodes[0];
 	node_max[0] = nodes[1] = node_last[1] = nodes[0] + node_num_max;
@@ -76,7 +78,7 @@ template <typename REAL>
 
 	nodes[0] = (Node*) malloc(2*node_num_max*sizeof(Node));
 	arcs[0] = (Arc*) malloc(2*arc_num_max*sizeof(Arc));
-	if (!nodes[0] || !arcs[0]) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
+   if (!nodes[0] || !arcs[0]) { if (error_function) (*error_function)((char*)("Not enough memory!")); exit(1); }
 
 	node_last[0] = nodes[0] + node_num;
 	node_max[0] = nodes[1] = nodes[0] + node_num_max;
@@ -176,7 +178,7 @@ template <typename REAL>
 
 	int node_num_max = node_num_max_new;
 	nodes[0] = (Node*) realloc(nodes_old[0], 2*node_num_max*sizeof(Node));
-	if (!nodes[0]) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
+   if (!nodes[0]) { if (error_function) (*error_function)((char*)("Not enough memory!")); exit(1); }
 
 	node_shift = node_num_max*sizeof(Node);
 	node_last[0] = nodes[0] + node_num;
@@ -208,7 +210,7 @@ template <typename REAL>
 	Arc* arcs_old[2] = { arcs[0], arcs[1] };
 
 	arcs[0] = (Arc*) realloc(arcs_old[0], 2*arc_num_max*sizeof(Arc));
-	if (!arcs[0]) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
+   if (!arcs[0]) { if (error_function) (*error_function)((char*)("Not enough memory!")); exit(1); }
 
 	arc_shift = arc_num_max*sizeof(Arc);
 	arc_max[0] = arcs[1] = arcs[0] + arc_num_max;
@@ -330,12 +332,12 @@ template <typename REAL>
 				if (IsNode0(a->head)) delta += a->sister->r_cap + GetMate(a)->sister->r_cap;
 				else                  delta -= a->r_cap + GetMate(a)->r_cap;
 			}
-			fprintf(fp, "1 %d %d\n", i+1, delta);
+           fprintf(fp, "1 %d %d\n", i+1, (int)(delta));
 		}
 		for (e=GetNextEdgeId(-1); e>=0; e=GetNextEdgeId(e))
 		{
 			GetTwicePairwiseTerm(e, i, j, E00, E01, E10, E11);
-			fprintf(fp, "2 %d %d %d\n", i+1, j+1, E00 + E11 - E01 - E10);
+           fprintf(fp, "2 %d %d %d\n", i+1, j+1, int(E00 + E11 - E01 - E10));
 		}
 		fclose(fp);
 		return true;
@@ -940,4 +942,5 @@ template <typename REAL>
 	}
 }
 
+}}
 #include "instances.inc"
diff -rupNw QPBO-v1.3.src/QPBO_extra.cpp QPBO-v1.3.src-patched/QPBO_extra.cpp
--- QPBO-v1.3.src/QPBO_extra.cpp	2010-01-25 10:38:59.000000000 -0500
+++ QPBO-v1.3.src-patched/QPBO_extra.cpp	2017-09-06 15:02:16.638704004 -0400
@@ -4,11 +4,13 @@
 #include <stdio.h>
 #include <stdlib.h>
