Visual Studio Template from Configured Dynamic Link Library

Date Created: 05-09-2026

Overview

The purpose of this writeup is to document how I configure a Visual Studio Dynamic Link Library project and generate a reusable template for future projects. This tutorial covers creating a Dynamic Link Library project, adjusting default settings for better workflow, test-building the project, and exporting it as a Visual Studio template for repeat use.

Please Note: I create all of my Visual Studio templates for C language development.

Table of Contents

  1. Create a New Dynamic Link Library Project
  2. Adjust Default Settings
    1. Update Output and Intermediate Directory Paths
    2. Update Project Settings
    3. Remove Precompiled Headers and Extras
  3. Export as Visual Studio Template
  4. Download the exact template
  1. Open Visual Studio and create a new project.
  2. Search for and select Dynamic-Link Library (DLL).
  3. Click Next, configure the project name/path, then click Create.

Create Dynamic Link Library Project

Update DLL Path

Adjust Default Settings

Update Output and Intermediate Directory Paths

By default, Visual Studio places build artifacts in directories beside project files. I prefer centralizing generated files under a Build path for easier cleanup and consistency across projects.

  1. Right click the DLL project in Solution Explorer and select Properties.
  2. Ensure All Configurations and All Platforms are selected.
  3. Update Configuration Properties > General > Output Directory to:
$(SolutionDir)\Build\$(Platform)\$(Configuration)\
  1. Update Configuration Properties > General > Intermediate Directory to:
$(SolutionDir)\Build\Intermediate\$(Platform)\$(Configuration)\

Updated Output Directories

Update Project Settings

  1. Code hardening — C/C++ General
    1. In project Properties, go to Configuration Properties > C/C++ > General.
    2. Set Warning Level to Level 4 (/W4).
    3. Set Enable Address Sanitizer to Yes (/fsanitize=address) if it aligns with your environment and toolchain.
  2. Precompiled headers
    1. Go to Configuration Properties > C/C++ > Precompiled Headers.
    2. Set Precompiled Header to Not Using Precompiled Headers.
    3. Clear Precompiled Header File if it still references pch.h, then click Apply.
  3. CRT static linking (Debug)
    • PLEASE NOTE: I statically link the CRT by default for testing across Windows versions; skip if you prefer dynamic CRT (/MDd).
    1. Set the configuration dropdown to Debug and platform to what you support (for example All Platforms).
    2. Go to Configuration Properties > C/C++ > Code Generation.
    3. Set Runtime Library to Multi-threaded Debug (/MTd).
    4. Click Apply.
  4. CRT static linking (Release)
    • PLEASE NOTE: Same as Debug; skip if you prefer /MD.
    1. Set the configuration dropdown to Release.
    2. Go to Configuration Properties > C/C++ > Code Generation.
    3. Set Runtime Library to Multi-threaded (/MT).
    4. Click Apply.
  5. No PDB output for Release (optional)
    • PLEASE NOTE: Turning off linker debug info means Release binaries won’t ship with PDBs — useful only if that matches how you distribute DLLs.
    1. Set the configuration dropdown to Release.
    2. Go to Configuration Properties > Linker > Debugging.
    3. Set Generate Debug Info to No.
    4. Click Apply.

Remove Precompiled Headers and Extras

  1. Remove and Delete default files: pch.h, pch.cpp, and framework.h
  2. Change dllmain.cpp to dllmain.c
  3. Paste the following source code into dllmain.c
#include <Windows.h>

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    UNREFERENCED_PARAMETER(lpReserved);
    UNREFERENCED_PARAMETER(hModule);

    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

/* end of file */

Run a test build for Debug and Release (and each platform you care about) so the project builds without warnings or errors before you export the template.

Export as Visual Studio Template

  1. From the top menu, select Project > Export Template.
  2. Select Project Template, ensure the DLL project is selected, then click Next.
  3. Add template metadata and click Finish.

Export DLL Template Export DLL Template Path

  1. After exporting, the template is available when creating new projects.

DLL Template Available

Download the exact template

If you would like to use the exact templates from this series, you can download them from my GitLab repository: Download here