xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.14k stars 782 forks source link

fatal error LNK1104: cannot open file 'msvcprtd.lib' #4554

Closed feather179 closed 10 months ago

feather179 commented 10 months ago

Xmake Version

xmake v2.8.5+HEAD.debbd3ac3

Operating System Version and Architecture

Windows 11 专业版 23H2

Describe Bug

Microsoft Visual Studio Community 2022 (64 位) 升级至 版本 17.8.3 后,原本可以正常编译的工程,现在编译会失败 在最后 link 的时候,提示找不到 msvcprtd.lib 这个 lib 用 everything 搜是存在的

Expected Behavior

可以正常链接

Project Configuration

就是正常的工程配置

add_rules("mode.debug", "mode.release")

target("VideoToolBox") set_kind("binary") set_toolchains("msvc") set_languages("c++20") add_cxxflags("/Zc:__cplusplus")

add_files("main.cpp")

Additional Information and Error Logs

xmake -v 在最后一步链接时的 log:

[ 93%]: linking.debug VideoToolBox.exe link.exe -nologo -dynamicbase -nxcompat -machine:x64 -libpath:lib -libpath:D:\msys64\usr\local\bin -libpath:D:\Qt\6.6.1\msvc2019_64\lib -debug -pdb:build\windows\x64\debug\VideoToolBox.pdb Qt6OpenGL.lib Qt6OpenGLWidgets.lib avdevice.lib avutil.lib avcodec.lib avformat.lib swresample.lib swscale.lib SDL2.lib Qt6Guid.lib Qt6Widgetsd.lib Qt6Cored.lib ws2_32.lib gdi32.lib ole32.lib advapi32.lib shell32.lib user32.lib opengl32.lib imm32.lib winmm.lib iphlpapi.lib -subsystem:windows -entry:mainCRTStartup -out:build\windows\x64\debug\VideoToolBox.exe build.objs\VideoToolBox\windows\x64\debug\main.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\Decoder.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\FFBuffer.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\Log.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\MainWindow.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\PacketBuffer.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\Render.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\ScreenRecorder.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\Semaphore.cpp.obj build.objs\VideoToolBox\windows\x64\debug\src\VideoGLWidget.cpp.obj build.objs\VideoToolBox\windows\x64\debug\ui\ScreenRecorderWidget.cpp.obj build.objs\VideoToolBox\windows\x64\debug\ui\VideoPlayerWidget.cpp.obj build.objs\VideoToolBox\windows\x64\debug\foundation\Base64.cpp.obj build.objs\VideoToolBox\windows\x64\debug\foundation\BitReader.cpp.obj build.objs\VideoToolBox\windows\x64\debug\foundation\BitWriter.cpp.obj build.objs\VideoToolBox\windows\x64\debug\foundation\MD5.cpp.obj build.objs\VideoToolBox\windows\x64\debug\foundation\Utils.cpp.obj build.objs\VideoToolBox\windows\x64\debug\client\RtpClientStream.cpp.obj build.objs\VideoToolBox\windows\x64\debug\client\RtspClientHelper.cpp.obj build.objs\VideoToolBox\windows\x64\debug\client\SdpClientHelper.cpp.obj build.objs\VideoToolBox\windows\x64\debug\server\RtpServerProto.cpp.obj build.objs\VideoToolBox\windows\x64\debug\server\RtpServerStream.cpp.obj build.objs\VideoToolBox\windows\x64\debug\server\RtspProgram.cpp.obj build.objs\VideoToolBox\windows\x64\debug\server\RtspServerHelper.cpp.obj build.objs\VideoToolBox\windows\x64\debug\server\SdpServerHelper.cpp.obj build.objs\VideoToolBox\windows\x64\debug\gens\ui\moc_ScreenRecorderWidget.cpp.obj build.objs\VideoToolBox\windows\x64\debug\gens\ui\moc_VideoPlayerWidget.cpp.obj error: LINK : fatal error LNK1104: cannot open file 'msvcprtd.lib'

这个库在电脑上的路径: D:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\lib\x64\msvcprtd.lib

visual studio 中,工程右键属性里面,vc++ 目录 -> 库目录 里面,包含了上面 lib 对应的目录

waruqi commented 10 months ago

执行下

xmake g -c
xmake f -c

试试

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


Execute

xmake g -c
xmake f -c

try

feather179 commented 10 months ago

感谢大大,测试可以了 不过是什么原因呢? 我如果直接整个删除 "build" 目录,再重新 "xmake f" 是不是也可以呢?(现在已经可以 build pass 没办法测试了...)

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


Thank you so much, I can test it now But what is the reason? Is it okay if I just delete the entire "build" directory and run "xmake f" again? (Build pass is now available and cannot be tested...)

waruqi commented 10 months ago

vs 环境探测有全局缓存,升级版本得清下

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


VS environment detection has a global cache, and the upgraded version is also cleared.