diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000000000000000000000000000000000000..d1e4404a3613e5d1cc38a2f27aa3d750d0db2de2
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "dlfcn-win32"]
+	path = dlfcn-win32
+	url = https://github.com/dlfcn-win32/dlfcn-win32.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 70cd1703807158f5af893bd044864b256fea61a6..1873500d2a3cd350d10a1db0882505b9cd916414 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.19)
 
 project(eisgenerator LANGUAGES C CXX)
 
+set (CMAKE_CXX_STANDARD 20)
+
 set(SRC_FILES
 	componant.cpp
 	cap.cpp
@@ -22,7 +24,7 @@ set(SRC_FILES
 	strops.cpp
 	translators.cpp
 	randomgen.cpp
-	compile.cpp
+	compcache.cpp
 )
 
 set(API_HEADERS_CPP_DIR eisgenerator/)
@@ -53,15 +55,37 @@ if(WIN32)
 	file(GLOB_RECURSE ARGP_SRC ${PROJECT_SOURCE_DIR}/argp/*.*)
 	set(SRC_FILES ${SRC_FILES} ${ARGP_SRC})
 	include_directories(./argp)
+	include_directories(./dlfcn-win32/src/)
+
+	set(SRC_FILES ${SRC_FILES}
+		compile-win.cpp
+		./dlfcn-win32/src/dlfcn.c
+	)
+
+	set(COMMON_LINK_FLAGS "-flto -dl")
 else()
 	message("Building on UNIX")
+
+	set(SRC_FILES ${SRC_FILES}
+		compile.cpp
+	)
+	set(COMMON_LINK_FLAGS "-flto -ltbb -pthread")
 endif(WIN32)
 
 
-add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${API_HEADERS_CPP})
-target_link_libraries(${PROJECT_NAME} ${LIBS})
-target_include_directories(${PROJECT_NAME} PUBLIC eisgenerator)
-set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-std=c++2a -Wall -O2 -march=native -g" LINK_FLAGS "-flto -ltbb -pthread")
+add_library(${PROJECT_NAME}_obj OBJECT ${SRC_FILES} ${API_HEADERS_CPP})
+target_link_libraries(${PROJECT_NAME}_obj ${LIBS})
+target_include_directories(${PROJECT_NAME}_obj PUBLIC eisgenerator)
+set_target_properties(${PROJECT_NAME}_obj PROPERTIES POSITION_INDEPENDENT_CODE 1)
+set_target_properties(${PROJECT_NAME}_obj PROPERTIES COMPILE_FLAGS "-Wall -O2 -march=native -g" LINK_FLAGS ${COMMON_LINK_FLAGS})
+add_library(${PROJECT_NAME} SHARED $<TARGET_OBJECTS:${PROJECT_NAME}_obj>)
+add_library(${PROJECT_NAME}_static STATIC $<TARGET_OBJECTS:${PROJECT_NAME}_obj>)
+
+if(WIN32)
+	set(EISGEN_LINK_FLAG ${PROJECT_NAME}_static)
+else()
+	set(EISGEN_LINK_FLAG ${PROJECT_NAME})
+endif(WIN32)
 
 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 	set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE)
@@ -82,20 +106,20 @@ GROUP_READ GROUP_EXECUTE )
 
 link_directories(${CMAKE_CURRENT_BINARY_DIR})
 set(SRC_FILES_TEST_APP test.cpp)
-set(LIBS_TEST -L. -l${PROJECT_NAME})
+set(LIBS_TEST -L. -l${EISGEN_LINK_FLAG})
 add_executable(${PROJECT_NAME}_test ${SRC_FILES_TEST_APP})
 add_dependencies(${PROJECT_NAME}_test ${PROJECT_NAME})
 target_link_libraries(${PROJECT_NAME}_test ${LIBS_TEST})
 target_include_directories(${PROJECT_NAME}_test PUBLIC eisgenerator)
-set_target_properties(${PROJECT_NAME}_test PROPERTIES COMPILE_FLAGS "-std=c++2a -Wall -O2 -march=native -g" LINK_FLAGS "-flto")
+set_target_properties(${PROJECT_NAME}_test PROPERTIES COMPILE_FLAGS "-Wall -O2 -march=native -g" LINK_FLAGS ${COMMON_LINK_FLAGS})
 install(TARGETS ${PROJECT_NAME}_test DESTINATION bin)
 
 link_directories(${CMAKE_CURRENT_BINARY_DIR})
 set(SRC_FILES_TEST_APP main.cpp)
-set(LIBS_TEST -L. -l${PROJECT_NAME})
+set(LIBS_TEST -L. -l${EISGEN_LINK_FLAG})
 add_executable(${PROJECT_NAME}_export ${SRC_FILES_TEST_APP})
 add_dependencies(${PROJECT_NAME}_export ${PROJECT_NAME})
 target_link_libraries(${PROJECT_NAME}_export ${LIBS_TEST})
 target_include_directories(${PROJECT_NAME}_export PUBLIC eisgenerator)
-set_target_properties(${PROJECT_NAME}_export PROPERTIES COMPILE_FLAGS "-std=c++2a -Wall -O2 -march=native -g" LINK_FLAGS "-flto")
+set_target_properties(${PROJECT_NAME}_export PROPERTIES COMPILE_FLAGS "-Wall -O2 -march=native -g" LINK_FLAGS ${COMMON_LINK_FLAGS})
 install(TARGETS ${PROJECT_NAME}_export DESTINATION bin)
diff --git a/compile.cpp b/compile.cpp
index 00b86298c610a1bfce02b22effc2b9950834eb11..5134a883eb3212e792bf8b60c711b7eb92e55683 100644
--- a/compile.cpp
+++ b/compile.cpp
@@ -7,7 +7,6 @@
 #include <errno.h>
 #include <stdexcept>
 #include <sys/wait.h>
-#include <dlfcn.h>
 
 #include "log.h"
 
@@ -83,67 +82,3 @@ int eis::compile_code(const std::string& code, const std::string& outputName)
 	return -1;
 }
 
-std::string eis::getTempdir()
-{
-	char* tmpEnv = getenv("TMP");
-	char* tempEnv = getenv("TEMP");
-	char* tempDirEnv = getenv("TEMPDIR");
-
-	std::filesystem::path path;
-	if(tmpEnv && std::string(tmpEnv).length() > 1)
-		path = tmpEnv;
-	else if(tempEnv && std::string(tempEnv).length() > 1)
-		path = tempEnv;
-	else if(tempDirEnv && std::string(tempDirEnv).length() > 1)
-		path = tempDirEnv;
-	else
-		path = "/tmp";
-	path = path/"eis_models";
-
-	if(!std::filesystem::is_directory(path))
-	{
-		if(!std::filesystem::create_directory(path))
-			throw std::runtime_error(path.string() +
-				"is not a directory and a directory can not be created at this locaion");
-	}
-
-	return path;
-}
-
-
-CompCache* CompCache::getInstance()
-{
-	if(!instance)
-		instance = new CompCache();
-	return instance;
-}
-
-bool CompCache::addObject(size_t uuid, const CompiledObject& object)
-{
-	CompiledObject* foundobject = getObject(uuid);
-	if(foundobject)
-		return false;
-
-	objects.insert({uuid, new CompiledObject(object)});
-	return true;
-}
-
-CompiledObject* CompCache::getObject(size_t uuid)
-{
-	auto search = objects.find(uuid);
-	if(search == objects.end())
-		return nullptr;
-	else
-		return search->second;
-}
-
-void CompCache::dropAllObjects()
-{
-	for(std::pair<size_t, CompiledObject*> object : objects)
-	{
-		dlclose(object.second->objectCode);
-		delete object.second;
-	}
-
-	objects.clear();
-}
diff --git a/compile.h b/compile.h
index ce0ababf8d84d189613ae5021faa17b6c0c08682..8c9b763452f3c552c6cbf0cfd19485f8c7c40db3 100644
--- a/compile.h
+++ b/compile.h
@@ -1,41 +1,8 @@
 #include <string>
-#include <vector>
-#include <map>
-#include <complex>
-
-#include "eistype.h"
 
 namespace eis
 {
 
 int compile_code(const std::string& code, const std::string& outputName);
 
-std::string getTempdir();
-
-struct CompiledObject
-{
-	void* objectCode;
-	std::vector<std::complex<fvalue>>(*symbol)(const std::vector<fvalue>&, const std::vector<fvalue>&);
-};
-
-class CompCache
-{
-public:
-
-private:
-
-	inline static CompCache* instance = nullptr;
-	std::map<size_t, CompiledObject*> objects;
-	CompCache() {};
-
-public:
-
-	static CompCache* getInstance();
-	CompCache(const CompCache&) = delete;
-	CompCache& operator=(const CompCache&) = delete;
-	bool addObject(size_t uuid, const CompiledObject& object);
-	CompiledObject* getObject(size_t uuid);
-	void dropAllObjects();
-};
-
 }
diff --git a/crossW64.cmake b/crossW64.cmake
index 22d72b57dce6f9f5f2e0016ac502693db727213a..37c1214302d93e5e01998f4f5832a9f1bb2abefa 100644
--- a/crossW64.cmake
+++ b/crossW64.cmake
@@ -5,3 +5,4 @@ set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_EXE_LINKER_FLAGS "-static")
diff --git a/dlfcn-win32 b/dlfcn-win32
new file mode 160000
index 0000000000000000000000000000000000000000..6444294ee354796536c34b54e154c0538a4d1eaf
--- /dev/null
+++ b/dlfcn-win32
@@ -0,0 +1 @@
+Subproject commit 6444294ee354796536c34b54e154c0538a4d1eaf
diff --git a/model.cpp b/model.cpp
index fd9d1ccfd7471e2de3f0da53cc3b752956cf36d6..84f11e9127cae0ab6a3e89ed75f8f0c3af8ce534 100644
--- a/model.cpp
+++ b/model.cpp
@@ -27,6 +27,7 @@
 #include "basicmath.h"
 #include "randomgen.h"
 #include "compile.h"
+#include "compcache.h"
 
 using namespace eis;
 
@@ -582,7 +583,7 @@ bool Model::compile()
 		size_t uuid = getUuid();
 
 		std::filesystem::path path = tmp/(std::to_string(getUuid())+".so");
-		int ret = compile_code(getCode(), path);
+		int ret = compile_code(getCode(), path.string());
 		if(ret != 0)
 		{
 			Log(Log::WARN)<<"Unable to compile model!! expect performance degredation";
@@ -590,7 +591,7 @@ bool Model::compile()
 		}
 
 		CompiledObject object;
-		object.objectCode = dlopen(path.c_str(), RTLD_NOW);
+		object.objectCode = dlopen(path.string().c_str(), RTLD_NOW);
 		if(!object.objectCode)
 			throw std::runtime_error("Unable to dlopen compiled model " + std::string(dlerror()));