Pre-built QuantLib as a Windows x64 DLL.
Upstream QuantLib blocks DLL builds on MSVC. This project patches the source to enable shared library builds and publishes pre-built binaries as GitHub Release assets.
Go to Releases and download the zip for your QuantLib version.
Extract to a directory of your choice (e.g. C:\quantlib-deps):
Expand-Archive QuantLib-1.41-x64-dll.zip -DestinationPath C:\quantlib-depsThis gives you:
C:\quantlib-deps\
QuantLib-1.41\
bin\QuantLib-x64-mt.dll # Runtime DLL
lib\QuantLib-x64-mt.lib # Import library for linking
include\ql\... # QuantLib headers (patched for DLL)
boost_1_87_0\
boost\... # Boost headers
Requirements: Visual Studio 2022 (C++ workload), CMake, 7-Zip.
.\scripts\Build-QuantLibDLL.ps1 -PackageZipBy default the working directory is build/ and the install directory is install/ inside the repo, so you can inspect the patched QuantLib sources at build\QuantLib-<version>\ after the build.
With custom versions and install location:
.\scripts\Build-QuantLibDLL.ps1 `
-QuantLibVersion 1.41 `
-BoostVersion 1.87.0 `
-InstallDir C:\Users\me\quantlib-deps\QuantLib-1.41 `
-PackageZipInclude the QuantLib test suite:
.\scripts\Build-QuantLibDLL.ps1 -BuildTests -PackageZipBuild and run the test suite:
.\scripts\Build-QuantLibDLL.ps1 -RunTests -PackageZipEight patches are applied to the QuantLib source to enable DLL builds:
| File | Patch |
|---|---|
cmake/Platform.cmake |
Remove FATAL_ERROR that blocks DLL builds on MSVC and suppress C4251 warnings |
ql/CMakeLists.txt |
Add RUNTIME DESTINATION so cmake --install copies the DLL |
ql/qldefines.hpp.cfg |
Inject QL_EXPORT / QL_IMPORT_ONLY macros for dllexport/dllimport |
ql/math/distributions/normaldistribution.hpp |
Add QL_EXPORT to InverseCumulativeNormal and MoroInverseCumulativeNormal |
ql/cashflows/lineartsrpricer.hpp |
Add QL_EXPORT to defaultLowerBound and defaultUpperBound static const members |
ql/experimental/math/gaussiancopulapolicy.hpp |
Add QL_EXPORT to density_ and cumulative_ static const members |
ql/math/randomnumbers/primitivepolynomials.hpp |
Add QL_EXPORT to PrimitivePolynomials extern array |
| Singleton DLL fix | Create ql/patterns/singleton.cpp with explicit template instantiations and add extern template declarations to each singleton header so only one copy of each singleton exists across DLL/EXE boundaries |
Patches 3–7 are needed because CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS does not export private static const class data members or extern "C" arrays. Without these patches, consumers get unresolved symbol errors at link time.
The singleton fix (patch 8) solves a separate problem: without it, both the DLL and any consuming EXE independently instantiate Singleton<T>::instance(), producing two separate singleton objects. This causes widespread test failures because, for example, Settings::instance().evaluationDate() set in the EXE has no effect on the DLL's own copy.
- Visual Studio 2022 (MSVC)
- CMake with
BUILD_SHARED_LIBS=ONandCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON - MSVC DLL CRT runtime (
/MD) - Boost headers only (no compiled Boost libraries needed)
This repository (build scripts and CI configuration) is licensed under the BSD 3-Clause License. QuantLib itself is licensed under the QuantLib License (BSD-modified).