# How to Install spdlog on Windows: Header-Only and Compiled Library Guide

> Learn to install spdlog on Windows as a header-only library or compiled CMake library. Optimize your project with this fast C++ logging library.

- Repository: [Gabi Melman/spdlog](https://github.com/gabime/spdlog)
- Tags: how-to-guide
- Published: 2026-07-15

---

**You can install spdlog on Windows either as a header-only library by copying the `include/spdlog` directory to your project, or as a compiled library using CMake and Visual Studio to reduce compile times and binary size.**

The `gabime/spdlog` repository provides multiple installation paths for Windows developers. Whether you need a quick drop-in solution or a performant compiled binary, the library supports both approaches with full compatibility for MSVC 2013 and newer. This guide covers the exact steps needed to integrate spdlog into your Windows C++ project based on the official source code structure.

## Installation Methods Overview

spdlog supports two primary installation modes on Windows. The **header-only** approach requires no building—simply copy the `include/spdlog` directory into your project. The **compiled library** approach, recommended for production use, involves generating a Visual Studio solution with CMake and building `spdlog.lib` (or `spdlog.dll`) to link against your application.

## Option 1: Header-Only Installation (Quickest)

The header-only method is the fastest way to start logging. It requires no build system configuration and works immediately with any C++11-compatible compiler on Windows.

### Manual Setup Steps

1. Download or clone the repository from `https://github.com/gabime/spdlog.git`
2. Copy the entire `include/spdlog` directory to your project's include path or your compiler's system include directory
3. Add the parent directory of `spdlog` to your compiler's include search path
4. Compile with MSVC 2013 or newer, or using the Cygwin toolchain

No linking step is required. The implementation resides entirely in the headers located in [`include/spdlog/spdlog.h`](https://github.com/gabime/spdlog/blob/main/include/spdlog/spdlog.h) and its dependencies.

## Option 2: Compiled Library Installation (Recommended)

Building spdlog as a compiled library significantly reduces compile times for downstream projects and produces smaller binaries. This is the recommended approach for production Windows applications.

### Building with CMake and Visual Studio

From the root of the cloned repository, execute these commands in a Developer Command Prompt:

```bash

# Clone the source

git clone https://github.com/gabime/spdlog.git
cd spdlog

# Create a build directory

mkdir build && cd build

# Generate Visual Studio solution (adjust generator for your version)

cmake .. -G "Visual Studio 16 2019" -A x64

# Optional: Build as shared library (DLL) instead of static

# cmake .. -G "Visual Studio 16 2019" -A x64 -DBUILD_SHARED_LIBS=ON

# Build the library

cmake --build . --config Release

```

The build process uses the root [`CMakeLists.txt`](https://github.com/gabime/spdlog/blob/main/CMakeLists.txt) to configure the project. Upon completion, you will find `spdlog.lib` (or `spdlog.dll` and its import library) in the build directory.

### Linking the Library

After building, configure your project to use the compiled library:

1. Add the `include` directory from the spdlog repository to your compiler's include path
2. Link against `spdlog.lib` (add it to your linker inputs)
3. If you built a shared library (`-DBUILD_SHARED_LIBS=ON`), ensure `spdlog.dll` is in your PATH or executable directory

The example [`example/CMakeLists.txt`](https://github.com/gabime/spdlog/blob/main/example/CMakeLists.txt) in the repository demonstrates how to properly consume the compiled library using `find_package(spdlog REQUIRED)`.

## Package Manager Installation (Alternative)

For automated dependency management, use these Windows package managers:

### vcpkg

```bash
vcpkg install spdlog

```

This command fetches a pre-built binary and configures include/library paths automatically. The vcpkg portfile (`vcpkg/ports/spdlog/portfile.cmake` in the repository) handles the CMake configuration for you.

### Conan

```bash
conan install spdlog/[*]

```

Conan resolves dependencies and generates the necessary configuration for your build system.

## Usage Examples

### Header-Only Usage

Create a [`main.cpp`](https://github.com/gabime/spdlog/blob/main/main.cpp) file with no additional linking required:

```cpp
#include "spdlog/spdlog.h"

int main() {
    spdlog::info("spdlog works on Windows – header-only!");
    spdlog::warn("A warning with a number: {}", 42);
    return 0;
}

```

Compile with: `cl /std:c++11 /EHsc main.cpp /I path\to\spdlog\include`

### Compiled Library Usage

When using the compiled library, link against the built target:

```cpp
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>

int main() {
    auto console = spdlog::stdout_color_mt("console");
    console->info("Compiled spdlog on Windows – ready to go!");
    return 0;
}

```

For CMake projects, use this configuration:

```cmake
cmake_minimum_required(VERSION 3.8)
project(MyApp)

find_package(spdlog REQUIRED)

add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE spdlog::spdlog)

```

## Summary

- **Header-only** installation requires copying `include/spdlog` to your project and works with MSVC 2013+ without linking
- **Compiled library** installation uses CMake to generate Visual Studio solutions, producing `spdlog.lib` or `spdlog.dll` for faster compile times
- The root [`CMakeLists.txt`](https://github.com/gabime/spdlog/blob/main/CMakeLists.txt) controls the build process and installation targets
- Package managers like **vcpkg** and **Conan** provide pre-built Windows binaries with automatic configuration
- The primary public header [`include/spdlog/spdlog.h`](https://github.com/gabime/spdlog/blob/main/include/spdlog/spdlog.h) provides the complete logging API in both installation modes

## Frequently Asked Questions

### Should I use header-only or compiled spdlog on Windows?

Use the **compiled library** for production projects to reduce compile times and binary size. Use **header-only** only for quick prototypes or when you cannot modify your build system to link external libraries, as the header-only mode increases compilation time for every source file that includes spdlog headers.

### What Visual Studio versions are supported?

The `gabime/spdlog` source code supports MSVC 2013 and newer. When running CMake, specify the generator matching your installed version (e.g., "Visual Studio 16 2019" or "Visual Studio 17 2022"). The library also works with MinGW and Cygwin toolchains on Windows.

### How do I link spdlog as a DLL on Windows?

Pass `-DBUILD_SHARED_LIBS=ON` to CMake when generating the Visual Studio solution. This creates `spdlog.dll` and its import library. Link against the import library in your project and ensure `spdlog.dll` is available in your executable's directory or system PATH at runtime.

### Can I use spdlog with MinGW or Cygwin on Windows?

Yes. The header-only mode works with any C++11-compatible compiler including MinGW and Cygwin. For the compiled library, use the appropriate CMake generator (e.g., "MinGW Makefiles" or "Unix Makefiles") instead of the Visual Studio generator when building.