How to install Rust and resvg - prepared for static linked libraries for both 64- and 32-bits Windows

How to install Rust and resvg - prepared for static linked libraries for both 64- and 32-bits Windows

18th December 2025 by Admin

Why Rust and why resvg? 

I all started with MysticThumbs! MysticThumbs (https://mysticcoder.net/MysticThumbs) is a super-powerful thumbnail-generator for Windows. It covers many file types Windows doesn't natively support. Even better, it has it's own plugin support concept, allowing programmers to create their own thumbnail-rendering plugin for one or more file types.

MysticThumbs does a great job on most formats, but I saw room for improvement on the rendering of the Scalable Vector Graphics formats SVG and SVGZ. This is where the SVG Plugin for MysticThumbs comes in as a C/C++ Visual Studio 2022 project, resulting in two DLLs named VCSVGPlugin64.mtp and VCSVGPlugin32.mtp (mtp is MysticThumbs plugin dll file extension).

Briefly the plugin uses resvg to render SVGs. resvg has been built as a statically linked library for both x64 and x86. This documents how.

Prepared for statically linked libraries for both x64 and Win32 (MSVC /MT)

This guide describes how to:

  • Install the Rust toolchain on Windows 11
  • Build resvg with its C API
  • Produce statically linked libraries
  • Support both x64 and Win32
  • Link everything into a /MT-based C/C++ plugin (single DLL, no need for shipping resvg.dll)

The result is a self-contained binary suitable for plugin distribution (e.g. MysticThumbs).


1. Prerequisites

Required software

  • Windows 11 - would probably work on anything VS2022 can run on too

  • Visual Studio 2022 - I use community editon.

    • Workload: Desktop development with C++

    • Components:

      • MSVC v143

      • Windows 10/11 SDK

  • Git for Windows (see https://git-scm.com/install/windows)

Recommended terminals

  • x64 Native Tools Command Prompt for VS 2022

  • x86 Native Tools Command Prompt for VS 2022

These ensure the correct MSVC toolchain is active.

Hint: Just start typing, such as "x64 Native" ... in the Windows Search-field


2. Install Rust using rustup (MSVC toolchain)

Download and run:

Choose the default installation.

Verify installation:

rustup show
rustc --version
cargo --version

Ensure the MSVC toolchain is active:

rustup default stable
rustup target add x86_64-pc-windows-msvc
rustup target add i686-pc-windows-msvc

3. Clone the resvg repository

The resvg-repository (https://github.com/linebender/resvg) can be installed wherever you want resvg to be installed. I have D:/Dev as my local development repository, and I have placed resvg inside the Rust-subdirectory, like this:

cd /d D:/Dev/Rust
git clone https://github.com/linebender/resvg.git
cd resvg

4. Install cargo-c (required for C API output)

The cargo-c tool produces C-friendly headers and libraries.

cargo install cargo-c

Verify:

cargo cinstall --version

Documentation:


5. Build static resvg C API – x64

Remember that the resvg-repository is now located in a directory such as D:/Dev/Rust/resvg. After this step, you have used cargo-c to create the c-api headers, libraries and other artifacts. This end-result can be placed in another directory! My toolkits lands in D:DevToolkits. For resvg I have chosen to create two separate directories, one for x64 and one for x86, like this:

D:/Dev/Toolkits/resvg-capi/x64
D:/Dev/Toolkits/resvg-capi/x86

Open x64 Native Tools Command Prompt for VS 2022.

set PREFIX=D:/Dev/Toolkits/resvg-capi/x64
set RUSTFLAGS=-C target-feature=+crt-static
cargo cinstall --release --locked ^
 --manifest-path crates/c-api/Cargo.toml ^
 --target x86_64-pc-windows-msvc ^
 --prefix %PREFIX%

Resulting layout:

D:/Dev/Toolkits/resvg-capi/x64
 ├─ include
 │ └─ resvg
 │ └─ resvg.h
 └─ lib
 └─ *.lib (static library)

6. Build static resvg C API – Win32 (x86)

Open x86 Native Tools Command Prompt for VS 2022.

set PREFIX=D:/Dev/Toolkits/resvg-capi/x86 
set RUSTFLAGS=-C target-feature=+crt-static
cargo cinstall --release --locked ^
 --manifest-path crates/c-api/Cargo.toml ^
  --target i686-pc-windows-msvc ^
   --prefix %PREFIX%

Resulting layout:

D:/Dev/Toolkits/resvg-capi/x86
 ├─ include
 │ └─ resvg
 │ └─ resvg.h
 └─ lib
 └─ *.lib (32-bit static library)

7. Visual Studio integration (per configuration)

Each configuration (such as Debug and Release) and each platform (such as x64 and x86) must point to the resvg-artifacts (the resvg.h and the library files).

Include paths

Add one include directory per platform:

  • x64: D:/Dev/Toolkits/resvg-capi/x64/include

  • x86: D:/Dev/Toolkits/resvg-capi/x86/include

Include in code:

#include <resvg/resvg.h>

Library paths

  • x64: D:/Dev/Toolkits/resvg-capi/x64/lib

  • x86: D:/Dev/Toolkits/resvg-capi/x86/lib

Add the static .lib file to:

  • Linker → Input → Additional Dependencies

⚠️ Do not link an import library for a DLL. If linked correctly, no resvg.dll will be required.

I have referenced the resvg.lib library like this - also note the other libraries that resvg.lib is dependent on

// Needed when linking resvg.lib (Rust std dependencies on Windows)
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "Userenv.lib")
#pragma comment(lib, "ntdll.lib")
// resvg STATIC LINKED import library
// Specified in Project Properties -> Linker -> Additional Library Directories / Dependencies.
#pragma comment(lib, "resvg.lib")


8. Runtime model compatibility

This setup assumes:

  • Your plugin uses /MT (static CRT)

  • Rust uses +crt-static

This avoids:

  • vcruntime*.dll

  • msvcp*.dll

  • resvg.dll

The final plugin is self-contained.


9. Verification

Check DLL dependencies

My plugin happens to be called VCSVGPlugin32.mtp or VCSVGPlugin64.mtp, but remember, .mtp is the MysticThumbs-speak for a .dll.

dumpbin /dependents YourPlugin.dll

Expected output:

  • Only Windows system DLLs

  • ❌ No resvg.dll

  • ❌ No VC runtime DLLs

Optional deep checks

dumpbin /imports YourPlugin.dll
dumpbin /symbols YourPlugin.dll

Both should show no dynamic resvg references.


10. Useful references


Final result

You end up with:

  • One single plugin binary

  • No external Rust or resvg runtime dependencies

  • Support for both x64 and x86 (Win32)

  • Clean, reproducible builds

This is pretty much the gold standard for shipping a native Windows plugin using Rust internally.


Login to post a comment

How to install Rust and resvg - prepared for static linked libraries for both 64- and 32-bits Windows

How to install Rust and resvg - prepared for static linked libraries for both 64- and 32-bits Windows

18th December 2025 by Admin

Why Rust and why resvg? 

I all started with MysticThumbs! MysticThumbs (https://mysticcoder.net/MysticThumbs) is a super-powerful thumbnail-generator for Windows. It covers many file types Windows doesn't natively support. Even better, it has it's own plugin support concept, allowing programmers to create their own thumbnail-rendering plugin for one or more file types.

MysticThumbs does a great job on most formats, but I saw room for improvement on the rendering of the Scalable Vector Graphics formats SVG and SVGZ. This is where the SVG Plugin for MysticThumbs comes in as a C/C++ Visual Studio 2022 project, resulting in two DLLs named VCSVGPlugin64.mtp and VCSVGPlugin32.mtp (mtp is MysticThumbs plugin dll file extension).

Briefly the plugin uses resvg to render SVGs. resvg has been built as a statically linked library for both x64 and x86. This documents how.

Prepared for statically linked libraries for both x64 and Win32 (MSVC /MT)

This guide describes how to:

  • Install the Rust toolchain on Windows 11
  • Build resvg with its C API
  • Produce statically linked libraries
  • Support both x64 and Win32
  • Link everything into a /MT-based C/C++ plugin (single DLL, no need for shipping resvg.dll)

The result is a self-contained binary suitable for plugin distribution (e.g. MysticThumbs).


1. Prerequisites

Required software

  • Windows 11 - would probably work on anything VS2022 can run on too

  • Visual Studio 2022 - I use community editon.

    • Workload: Desktop development with C++

    • Components:

      • MSVC v143

      • Windows 10/11 SDK

  • Git for Windows (see https://git-scm.com/install/windows)

Recommended terminals

  • x64 Native Tools Command Prompt for VS 2022

  • x86 Native Tools Command Prompt for VS 2022

These ensure the correct MSVC toolchain is active.

Hint: Just start typing, such as "x64 Native" ... in the Windows Search-field


2. Install Rust using rustup (MSVC toolchain)

Download and run:

Choose the default installation.

Verify installation:

rustup show
rustc --version
cargo --version

Ensure the MSVC toolchain is active:

rustup default stable
rustup target add x86_64-pc-windows-msvc
rustup target add i686-pc-windows-msvc

3. Clone the resvg repository

The resvg-repository (https://github.com/linebender/resvg) can be installed wherever you want resvg to be installed. I have D:/Dev as my local development repository, and I have placed resvg inside the Rust-subdirectory, like this:

cd /d D:/Dev/Rust
git clone https://github.com/linebender/resvg.git
cd resvg

4. Install cargo-c (required for C API output)

The cargo-c tool produces C-friendly headers and libraries.

cargo install cargo-c

Verify:

cargo cinstall --version

Documentation:


5. Build static resvg C API – x64

Remember that the resvg-repository is now located in a directory such as D:/Dev/Rust/resvg. After this step, you have used cargo-c to create the c-api headers, libraries and other artifacts. This end-result can be placed in another directory! My toolkits lands in D:DevToolkits. For resvg I have chosen to create two separate directories, one for x64 and one for x86, like this:

D:/Dev/Toolkits/resvg-capi/x64
D:/Dev/Toolkits/resvg-capi/x86

Open x64 Native Tools Command Prompt for VS 2022.

set PREFIX=D:/Dev/Toolkits/resvg-capi/x64
set RUSTFLAGS=-C target-feature=+crt-static
cargo cinstall --release --locked ^
 --manifest-path crates/c-api/Cargo.toml ^
 --target x86_64-pc-windows-msvc ^
 --prefix %PREFIX%

Resulting layout:

D:/Dev/Toolkits/resvg-capi/x64
 ├─ include
 │ └─ resvg
 │ └─ resvg.h
 └─ lib
 └─ *.lib (static library)

6. Build static resvg C API – Win32 (x86)

Open x86 Native Tools Command Prompt for VS 2022.

set PREFIX=D:/Dev/Toolkits/resvg-capi/x86 
set RUSTFLAGS=-C target-feature=+crt-static
cargo cinstall --release --locked ^
 --manifest-path crates/c-api/Cargo.toml ^
  --target i686-pc-windows-msvc ^
   --prefix %PREFIX%

Resulting layout:

D:/Dev/Toolkits/resvg-capi/x86
 ├─ include
 │ └─ resvg
 │ └─ resvg.h
 └─ lib
 └─ *.lib (32-bit static library)

7. Visual Studio integration (per configuration)

Each configuration (such as Debug and Release) and each platform (such as x64 and x86) must point to the resvg-artifacts (the resvg.h and the library files).

Include paths

Add one include directory per platform:

  • x64: D:/Dev/Toolkits/resvg-capi/x64/include

  • x86: D:/Dev/Toolkits/resvg-capi/x86/include

Include in code:

#include <resvg/resvg.h>

Library paths

  • x64: D:/Dev/Toolkits/resvg-capi/x64/lib

  • x86: D:/Dev/Toolkits/resvg-capi/x86/lib

Add the static .lib file to:

  • Linker → Input → Additional Dependencies

⚠️ Do not link an import library for a DLL. If linked correctly, no resvg.dll will be required.

I have referenced the resvg.lib library like this - also note the other libraries that resvg.lib is dependent on

// Needed when linking resvg.lib (Rust std dependencies on Windows)
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "Userenv.lib")
#pragma comment(lib, "ntdll.lib")
// resvg STATIC LINKED import library
// Specified in Project Properties -> Linker -> Additional Library Directories / Dependencies.
#pragma comment(lib, "resvg.lib")


8. Runtime model compatibility

This setup assumes:

  • Your plugin uses /MT (static CRT)

  • Rust uses +crt-static

This avoids:

  • vcruntime*.dll

  • msvcp*.dll

  • resvg.dll

The final plugin is self-contained.


9. Verification

Check DLL dependencies

My plugin happens to be called VCSVGPlugin32.mtp or VCSVGPlugin64.mtp, but remember, .mtp is the MysticThumbs-speak for a .dll.

dumpbin /dependents YourPlugin.dll

Expected output:

  • Only Windows system DLLs

  • ❌ No resvg.dll

  • ❌ No VC runtime DLLs

Optional deep checks

dumpbin /imports YourPlugin.dll
dumpbin /symbols YourPlugin.dll

Both should show no dynamic resvg references.


10. Useful references


Final result

You end up with:

  • One single plugin binary

  • No external Rust or resvg runtime dependencies

  • Support for both x64 and x86 (Win32)

  • Clean, reproducible builds

This is pretty much the gold standard for shipping a native Windows plugin using Rust internally.


Login to post a comment