Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Build/Windows] Linker errors (LNK2038 / LNK2005 / LNK1120) when building with MSVC toolchain

Closed
#70 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
cpp, rust
Domain
build-system

Research direction

Start by reproducing with config/codetrial.env.local using cargo build or cargo run -- web on the stable MSVC toolchain. Trace the livekit/libwebrtc-sys dependency while reviewing the libcpmt.lib, msvcprt.lib, and linker diagnostics. Done means the Windows MSVC build links without runtime mismatch, duplicate-symbol, or unresolved-symbol errors.

Written by the indexing model from the issue text.

Description

Environment
  • git version: fadcbfb
  • OS: Windows 11 (x86_64)
  • Rust Toolchain: stable-x86_64-pc-windows-msvc (rustc 1.98.1)
  • MSVC Build Tools: Visual Studio 2022 (v143)
Steps to Reproduce
  1. Clone the repository: git clone https://github.com/sysprog21/codetrial.git
  2. Create config: cp config/codetrial.env.example config/codetrial.env.local
  3. Setup the required keys in config/codetrial.env.local
  4. Run cargo run -- web (or cargo build)
Actual Behavior

The build fails at the final linking phase with MSVC CRT runtime mismatch errors (LNK2038, LNK2005, LNK1120) between libcpmt.lib (static CRT) and libwebrtc_sys (dynamic CRT):

libcpmt.lib(xlocale.obj) : error LNK2038: 偵測到 'RuntimeLibrary' 不符: 'MT_StaticRelease' 值與 'MD_DynamicRelease' 值 (位於 libwebrtc_sys-ae90a033c9ff50e9.rlib) 不符
libcpmt.lib(xlocale.obj) : error LNK2005: "public: int __cdecl std::ios_base::flags(void)const" 已在 msvcprt.lib(MSVCP140.dll) 中定義過了
...
fatal error LNK1169: 找到有一或多個已定義的符號

When passing /NODEFAULTLIB:libcpmt.lib, the linker fails with missing symbols:

error LNK1120: 3 個無法解析的外部符號 (?_Id_cnt@id@locale@std@@0HA)
What could be the reason?
This might be the platform compatibility issue with WebRTC C++ bindings (libwebrtc-sys) on Windows MSVC:
  • codetrial uses livekit which embeds recompiled C++ WebRTC binaries(libwebrtc-sys).
  • On Windows, different C/C++ dependencies in the Rust build graph requested different C Runtime Libraries (/MD dynamic vs /MT static).
  • When MSVC links libcpmt.lib and msvcprt.lib together, it throws LNK2038 (RuntimeLibrary mismatch) and LNK2005 (duplicate symbols). When ignored, it results in LNK1120 (unresolved symbols).
Dominant language
Rust
Stars
94
Forks
27
Avg merge
1d 1h
Merged PRs (30d)
79

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/codetrial

All issues in sysprog21/codetrial

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.