Checkout the sources from GitHub:
Open ide/vs2022/mimalloc.sln in Visual Studio 2022 and build. The mimalloc-lib project builds a static library (in out/msvc-x64), while the mimalloc-override-dll project builds a DLL for overriding malloc in the entire program.
We use cmake as the build system:
This builds the library as a shared (dynamic) library (.so or .dylib), a static library (.a), and as a single object file (.o).
> sudo make install (install the library and header files in /usr/local/lib and /usr/local/include)
You can build the debug version which does many internal checks and maintains detailed statistics as:
This will name the shared library as libmimalloc-debug.so.
Finally, you can build a secure version that uses guard pages, encrypted free lists, etc., as:
This will name the shared library as libmimalloc-secure.so. Use cmake ../.. -LH to see all the available build options.
The examples use the default compiler. If you like to use another, use:
You can also use cmake on Windows. Open a Visual Studio 2022 development prompt and invoke cmake with the right generator and architecture, like:
The cmake build type is specified when actually building, for example:
You can also install the LLVM toolset on Windows to build with the clang-cl compiler directly:
You can also directly build the single src/static.c file as part of your project without needing cmake at all. Make sure to also add the mimalloc include directory to the include path.