diff --git a/src/cluster/Makefile b/src/cluster/Makefile
index 3fc31183a257fd5a8b03603383f4b21d88a09231..8a117426a230df94df4ebb368d06d7e56ad23b5b 100644
--- a/src/cluster/Makefile
+++ b/src/cluster/Makefile
@@ -46,7 +46,7 @@ $(BUILDDIR_CLU)/edfb_clu: $(OBJDIR) $(OBJDIR)/edfb_clu.o $(BUILDDIR_CLU)
 
 # We put $(LIBNPTM) as an object to link in directly, so that it will be found at runtime even if it is a shared object library. May change in the future when we have an install: target
 $(BUILDDIR_CLU)/np_cluster: $(OBJDIR) $(CXX_CLU_OBJS) $(BUILDDIR_CLU) $(LIBNPTM)
-	$(CXX) $(CXXFLAGS) -o $(BUILDDIR_CLU)/np_cluster $(CXX_CLU_OBJS) $(LIBNPTM) $(CXXLDFLAGS) -llapacke
+	$(CXX) $(CXXFLAGS) -o $(BUILDDIR_CLU)/np_cluster $(CXX_CLU_OBJS) $(LIBNPTM) $(CXXLDFLAGS)
 
 clean:
 	rm -f $(F_CLU_OBJS) $(CXX_CLU_OBJS) $(CXX_CLU_DEBUG)
diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp
index ea86b7391d43f9b420f9bbfbcf9a16f3a16090c3..a31b2b71ca5abc4168643f07fdcf6ebda99307c7 100644
--- a/src/cluster/cluster.cpp
+++ b/src/cluster/cluster.cpp
@@ -33,6 +33,7 @@
 #endif
 
 #ifndef INCLUDE_LAPACK_CALLS_H_
+#include "lapacke.h"
 #include "../include/lapack_calls.h"
 #endif
 
@@ -340,7 +341,7 @@ void cluster(string config_file, string data_file, string output_path) {
 	} // i132 loop
 	cms(am, c1, c1ao, c4, c6);
 	//cms(tam, c1, c1ao, c4, c6);
-	int ndit = 2 * nsph * c4->nlim;
+	lapack_int ndit = 2 * nsph * c4->nlim;
 	//lucin(am, mxndm, ndit, jer);
 	zinvert(am, ndit, jer);
 	if (jer != 0) break; // jxi488 loop: goes to memory clean
diff --git a/src/include/lapack_calls.h b/src/include/lapack_calls.h
index 52996a53139c0f2e2a846abe06c11680a662bf0c..9c363e74469adaacb02f4bd62b28ece86660f251 100644
--- a/src/include/lapack_calls.h
+++ b/src/include/lapack_calls.h
@@ -16,6 +16,6 @@
  * \param n: `int` The number of rows and columns of the [n x n] matrix.
  * \param jer: `int &` Reference to an integer return flag.
  */
-void zinvert(std::complex<double> **mat, int n, int &jer);
+void zinvert(std::complex<double> **mat, lapack_int n, int &jer);
 
 #endif
diff --git a/src/libnptm/lapack_calls.cpp b/src/libnptm/lapack_calls.cpp
index f57e31dac87db4ec0c3c96dfd7ed80d060855d92..e22c5a84f545e22e91e8d88166f973d803d6e953 100644
--- a/src/libnptm/lapack_calls.cpp
+++ b/src/libnptm/lapack_calls.cpp
@@ -1,31 +1,31 @@
 #include <complex>
 #include <cstdlib>
-#include "lapacke.h"
 
 #ifndef INCLUDE_LAPACK_CALLS_H_
+#include "lapacke.h"
 #include "../include/lapack_calls.h"
 #endif
 
 using namespace std;
 
-void zinvert(std::complex<double> **mat, int n, int &jer) {
+void zinvert(std::complex<double> **mat, lapack_int n, int &jer) {
   jer = 0;
   __complex__ double *arr = new __complex__ double[n * n];
   const __complex__ double uim = 1.0di;
-  for (int i = 0; i < n; i++) {
-    for (int j = 0; j < n; j++) {
-      int idx = i + n * j;
+  for (lapack_int i = 0; i < n; i++) {
+    for (lapack_int j = 0; j < n; j++) {
+      lapack_int idx = i + n * j;
       arr[idx] = mat[j][i].real() + uim * mat[j][i].imag();
     }
   }
   
-  int* IPIV = new int[n];
+  int* IPIV = new int[n]();
   
   LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV);
   LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV);
-  for (int i = 0; i < n; i++) {
-    for (int j = 0; j < n; j++) {
-      int idx = i + n * j;
+  for (lapack_int i = 0; i < n; i++) {
+    for (lapack_int j = 0; j < n; j++) {
+      lapack_int idx = i + n * j;
       mat[j][i] = complex<double>(__real__ arr[idx], __imag__ arr[idx]);
     }
   }
diff --git a/src/make.inc b/src/make.inc
index dcdd896f0619de451fcf37eaeb62ec664f21c8e6..3779c034802c64fbab301c084ecdf5c045c92243 100644
--- a/src/make.inc
+++ b/src/make.inc
@@ -40,7 +40,7 @@ endif
 
 # CXXFLAGS defines the default compilation options for the C++ compiler
 ifndef CXXFLAGS
-override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE)
+override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE) -DLAPACK_ILP64
 #override CXXFLAGS=-O3 -I$(HDF5_INCLUDE)
 endif
 
@@ -50,7 +50,7 @@ ifndef CXXLDFLAGS
 ifndef HDF5_LIB
 override HDF5_LIB=/usr/lib/x86_64-linux-gnu/hdf5/serial
 endif
-override CXXLDFLAGS=-L/usr/lib64 -L$(HDF5_LIB) -lhdf5 $(LDFLAGS)
+override CXXLDFLAGS=-L/usr/lib64 -L$(HDF5_LIB) -lhdf5 -llapacke $(LDFLAGS)
 #else
 #override CXXLDFLAGS=-L/usr/lib64 -L$(HDF5_LIB) -lhdf5 $(CXXLDFLAGS)
 endif