Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

[BUG] 编译时:error LNK2038: 检测到“RuntimeLibrary”的不匹配项 #13

Closed
MMitsuha opened this issue Jul 13, 2022 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@MMitsuha
Copy link

Describe the bug
编译时出现ucxxrt.lib(xthrow.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MTd_StaticDebug”不匹配值“MT_StaticRelease”ucxxrt.lib(throw_bad_alloc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MTd_StaticDebug”不匹配值“MT_StaticRelease”

To Reproduce
Steps to reproduce the behavior:
1.切换到Debug选项
2.编译

Expected behavior
出现LNK2038错误

Screenshots
image

Desktop (please complete the following information):

  • OS: [Windows 10]
  • Version [10.0.19044.1766]

Additional context

已启动生成...
1>------ 已启动生成: 项目: NtLoader, 配置: Debug x64 ------
1>
1>  **************************************************
1>  *         Universal C++ RunTime (UCXXRT)         *
1>  **************************************************
1>  
1>  UCXXRT Path      : C:\Users\cz251\source\repos\NtLoader\packages\ucxxrt.2.1.2\lib\native\
1>  Platform         : x64
1>  Configuration    : Debug
1>  Tools Version    : 14.32.31326
1>  Platform Version : 10.0.22621.0
1>  Kernel Mode      : true
1>Building 'NtLoader' with toolset 'WindowsKernelModeDriver10.0' and the 'Universal' target platform.
1>KLog.cpp
1>KMemory.cpp
1>Main.cpp
1>正在生成代码...
1>ucxxrt.lib(xthrow.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MTd_StaticDebug”不匹配值“MT_StaticRelease”(Main.obj 中)
1>ucxxrt.lib(throw_bad_alloc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MTd_StaticDebug”不匹配值“MT_StaticRelease”(Main.obj 中)
1>C:\Users\cz251\source\repos\NtLoader\x64\Debug\NtLoader.sys : fatal error LNK1319: 检测到 2 个不匹配项
1>已完成生成项目“NtLoader.vcxproj”的操作 - 失败。
========== “生成”: 0 成功,1 失败,0 更新,0 已跳过 ==========
@MMitsuha MMitsuha added the bug Something isn't working label Jul 13, 2022
@MiroKaku
Copy link
Owner

MiroKaku commented Jul 13, 2022

Debug 的项目配置缺少宏定义 _DEBUG (一般来说,VS 会默认带这个宏的)

EN: Debug's project configuration is missing the macro definition _DEBUG (usually, VS will have this macro by default)

@MiroKaku MiroKaku pinned this issue Jul 13, 2022
@MMitsuha
Copy link
Author

MMitsuha commented Jul 13, 2022

Debug 的项目配置缺少宏定义 _DEBUG (一般来说,VS 会默认带这个宏的)

EN: Debug's project configuration is missing the macro definition _DEBUG (usually, VS will have this macro by default)

但是我觉得是ucxxrt.lib是用release编译的,而我的是用debug的,所以出现了mt和mtd不对应的问题,运行库应该不是由宏来决定的吧,我切换到release编译就成功了

@MiroKaku
Copy link
Owner

ucxxrt的配置并没有错。_DEBUG 宏是STL的头文件里面需要的,头文件这部分并不会编译到ucxxrt

@MiroKaku
Copy link
Owner

Debug 的项目配置缺少宏定义 _DEBUG (一般来说,VS 会默认带这个宏的)
EN: Debug's project configuration is missing the macro definition _DEBUG (usually, VS will have this macro by default)

但是我觉得是ucxxrt.lib是用release编译的,而我的是用debug的,所以出现了mt和mtd不对应的问题,运行库应该不是由宏来决定的吧,我切换到release编译就成功了

更何况,错误提示已经指出了 ucxxrt 是 debug 的,而你的 ntloader 因为缺少 _DEBUG 被认为是 release 的

1>ucxxrt.lib(xthrow.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 
值“MTd_StaticDebug”不匹配值“MT_StaticRelease”(Main.obj 中)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1>ucxxrt.lib(throw_bad_alloc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 
值“MTd_StaticDebug”不匹配值“MT_StaticRelease”(Main.obj 中)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1>C:\Users\cz251\source\repos\NtLoader\x64\Debug\NtLoader.sys : fatal error LNK1319: 检测到 2 个不匹配项

@MiroKaku MiroKaku added the wontfix This will not be worked on label Jul 14, 2022
@MMitsuha
Copy link
Author

我更改了运行库,解决了,谢谢啦awa

@MiroKaku MiroKaku unpinned this issue Oct 29, 2022
MiroKaku added a commit that referenced this issue Oct 29, 2022
@MiroKaku MiroKaku removed the wontfix This will not be worked on label Oct 30, 2022
MiroKaku added a commit that referenced this issue Dec 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants