--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,6 +66,7 @@ if (NOT BUILD_C_BINDINGS)
     set(BUILD_MATLAB_BINDINGS OFF)
 endif()
 
+find_package(lz4 REQUIRED)
 
 # find python
 find_package(PythonInterp)
--- a/src/cpp/CMakeLists.txt
+++ b/src/cpp/CMakeLists.txt
@@ -4,11 +4,12 @@ add_definitions(-D_FLANN_VERSION=${FLANN_VERSION})
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flann/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/flann/config.h)
 
-file(GLOB_RECURSE C_SOURCES flann.cpp lz4.c lz4hc.c)
-file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp lz4.c lz4hc.c)
+file(GLOB_RECURSE C_SOURCES flann.cpp)
+file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp)
 file(GLOB_RECURSE CU_SOURCES *.cu)
 
 add_library(flann_cpp_s STATIC ${CPP_SOURCES})
+target_link_libraries(flann_cpp_s PUBLIC lz4::lz4)
 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
     set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC)
 endif()
@@ -42,10 +43,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
     endif()
 else()
     add_library(flann_cpp SHARED ${CPP_SOURCES})
+    target_link_libraries(flann_cpp PUBLIC lz4::lz4)
     if (BUILD_CUDA_LIB)
 		cuda_add_library(flann_cuda SHARED ${CPP_SOURCES})
         set_property(TARGET flann_cpp PROPERTY COMPILE_DEFINITIONS FLANN_USE_CUDA)
     endif()
+    set_target_properties(flann_cpp PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
 endif()
 
 set_target_properties(flann_cpp PROPERTIES
@@ -77,6 +80,7 @@ endif()
 
 if (BUILD_C_BINDINGS)
     add_library(flann_s STATIC ${C_SOURCES})
+    target_link_libraries(flann_s PUBLIC lz4::lz4)
     if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
         set_target_properties(flann_s PROPERTIES COMPILE_FLAGS -fPIC)
     endif()
@@ -88,6 +92,7 @@ if (BUILD_C_BINDINGS)
         target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive)
     else()
         add_library(flann SHARED ${C_SOURCES})
+        target_link_libraries(flann PUBLIC lz4::lz4)
 
         if(MINGW AND OPENMP_FOUND)
           target_link_libraries(flann gomp)
--- a/src/cpp/flann/util/serialization.h
+++ b/src/cpp/flann/util/serialization.h
@@ -6,8 +6,8 @@
 #include <cstdlib>
 #include <cstring>
 #include <stdio.h>
-#include "flann/ext/lz4.h"
-#include "flann/ext/lz4hc.h"
+#include <lz4.h>
+#include <lz4hc.h>
 
 
 namespace flann
