diff --git a/src/common/library.c b/src/common/library.c index c131a3862..554cc9f39 100644 --- a/src/common/library.c +++ b/src/common/library.c @@ -10,10 +10,12 @@ #endif #endif -#ifdef __SANITIZE_ADDRESS__ - #define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE -#else - #define FF_DLOPEN_FLAGS RTLD_LAZY +#ifndef FF_DLOPEN_FLAGS + #ifdef __SANITIZE_ADDRESS__ + #define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE + #else + #define FF_DLOPEN_FLAGS RTLD_LAZY + #endif #endif static void* libraryLoad(const char* path, int maxVersion) diff --git a/src/common/library.h b/src/common/library.h index 885cd32dc..fd12c0b05 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -3,7 +3,18 @@ #ifndef FF_INCLUDED_common_library #define FF_INCLUDED_common_library -#include +#include "fastfetch.h" +#include "util/FFcheckmacros.h" + +#if defined(_WIN32) //We don't force MSYS using LoadLibrary because dlopen also searches $LD_LIBRARY_PATH + #include + #define FF_DLOPEN_FLAGS 0 + FF_C_NODISCARD static inline void* dlopen(const char* path, int mode) { FF_UNUSED(mode); return LoadLibraryA(path); } + FF_C_NODISCARD static inline void* dlsym(void* handle, const char* symbol) { return GetProcAddress((HMODULE)handle, symbol); } + static inline int dlclose(void* handle) { return !FreeLibrary((HMODULE)handle); } +#else + #include +#endif #if defined(_WIN32) || defined(__MSYS__) #define FF_LIBRARY_EXTENSION ".dll"