[Build/Windows] Linker errors (LNK2038 / LNK2005 / LNK1120) when building with MSVC toolchain
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
- 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
- Clone the repository:
git clone https://github.com/sysprog21/codetrial.git - Create config:
cp config/codetrial.env.example config/codetrial.env.local - Setup the required keys in config/codetrial.env.local
- Run
cargo run -- web(orcargo 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sysprog21/codetrial
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
Maintainers usually reply within 1 day
All issues in sysprog21/codetrial
Similar issues
-
component:sight
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
agentic-os-org/ANOLISA#4115 · 1 comment ·
Maintainers usually reply within 1 day
-
A-io-database bug needs triage python
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Change output crossing a compactsize boundary leaves the fee slightly below the requested feerateOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bitcoindevkit/bdk_wallet#578 ·
Maintainers usually reply within 8 days
-
`python.analysis` setting changes (e.g. `completeFunctionParens`) are not picked up until reloadOpenlanguage-server
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days