简体   繁体   English

错误 MSB6006:“link.exe”以代码 1 退出运行 SDV(Static 驱动程序验证程序)时,Visual Studio 2019、SDK 10 build 19041、windows 10 build 19041

[英]error MSB6006: "link.exe" exited with code 1 When run SDV ( Static Driver Verifier) , Visual studio 2019 , SDK 10 build 19041, windows 10 build 19041

We create new KMDF USB project, Open visual studio 2019 v 16.11, go to File -> new -> project -> chose Kernel Mode Driver, USB (KMDF).我们创建新的 KMDF USB 项目,打开 visual studio 2019 v 16.11,go 到文件 -> 新建 -> 项目 -> 选择 Kernel 模式驱动程序,USB (KMDF)。 without any modification, this project have no error, no warning when building.没有任何修改,这个项目没有错误,构建时没有警告。 when we run SDV ( Static Driver Verifier) for this project the smvbuild.log show this error.当我们为此项目运行 SDV(Static Driver Verifier)时,smvbuild.log 显示此错误。

C:\Program Files (x86)\Windows Kits\10\TOOLS\SDV\smv\bin\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\tungpvt\source\repos\USB Driver2Release\USBDriver2.sys" /VERSION:"10.0" /INCREMENTAL:NO /NOLOGO /WX /SECTION:"INIT,d" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\BufferOverflowFastFailK.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\ntoskrnl.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\hal.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\wmilib.lib" "C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x86\1.15\WdfLdr.lib" "C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x86\1.15\WdfDriverEntry.lib" usbdex.lib ntstrsafe.lib "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\wpprecorder.lib" /NODEFAULTLIB /MANIFEST:NO /DEBUG /PDB:"C:\Users\tungpvt\source\repos\USB Driver2Release\USBDriver2.pdb" /SUBSYSTEM:NATIVE,"10.00" /Driver /OPT:REF /OPT:ICF /ENTRY:"FxDriverEntry@8" /RELEASE /IMPLIB:"C:\Users\tungpvt\source\repos\USB Driver2Release\USBDriver2.lib" /MERGE:"_TEXT=.text;_PAGE=PAGE" /MACHINE:X86 /PROFILE /SAFESEH /guard:cf /kernel /IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221 /osversion:10.0 /pdbcompress /debugtype:pdata Release\Device.obj
  Release\Driver.obj
  Release\Queue.obj
  
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(1074,5): error MSB6006: "link.exe" exited with code 1. [C:\Users\tungpvt\source\repos\USB Driver2\USB Driver2\USB Driver2.vcxproj]
Done executing task "Link" -- FAILED.
Done building target "Link" in project "USB Driver2.vcxproj" -- FAILED.
Done Building Project "C:\Users\tungpvt\source\repos\USB Driver2\USB Driver2\USB Driver2.vcxproj" (rebuild target(s)) -- FAILED.

In additional, when running the link.exe on command line, Visual studio -> Tools -> Command Line -> Developer Command Prompt with same parameter like above it shows:此外,当在命令行上运行 link.exe 时, Visual studio -> Tools -> Command Line -> Developer Command Prompt具有与上面相同的参数,它显示:

Failed to load Intercept.XML:
Could not find file 'c:\program files (x86)\windows kits\10\tools\sdv\smv\bin\%BE%-Intercept.xml'.

we've added the BE and smv variables to Windows system environment我们已经将 BE 和 smv 变量添加到 Windows 系统环境

variable name: BE , variable value: MSBuild
variable name: smv , variable value: C:\Program Files (x86)\Windows Kits\10\Tools\sdv\smv

In Linker session in Project properties, we modified Project properties -> Linker -> Input -> Additional Dependency to在Project properties中的Linker session,我们修改Project properties -> Linker -> Input -> Additional Dependency 为

%(AdditionalDependencies);$(DDK_LIB_PATH)usbdex.lib;$(DDK_LIB_PATH)ntstrsafe.lib

Then we can pass the command line然后我们可以通过命令行

C:\Program Files (x86)\Windows Kits\10\TOOLS\SDV\smv\bin\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\tungpvt\source\repos\USB Driver2Release\USBDriver2.sys" /VERSION:"10.0" /INCREMENTAL:NO /NOLOGO /WX /SECTION:"INIT,d" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\BufferOverflowFastFailK.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\ntoskrnl.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\hal.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\wmilib.lib" "C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x86\1.15\WdfLdr.lib" "C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x86\1.15\WdfDriverEntry.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\usbdex.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\ntstrsafe.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\km\x86\wpprecorder.lib" /NODEFAULTLIB /MANIFEST:NO /DEBUG /PDB:"C:\Users\tungpvt\source\repos\USB Driver2Release\USBDriver2.pdb" /SUBSYSTEM:NATIVE,"10.00" /Driver /OPT:REF /OPT:ICF /ENTRY:"FxDriverEntry@8" /RELEASE /IMPLIB:"C:\Users\tungpvt\source\repos\USB Driver2Release\USBDriver2.lib" /MERGE:"_TEXT=.text;_PAGE=PAGE" /MACHINE:X86 /PROFILE /SAFESEH /guard:cf /kernel /IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221 /osversion:10.0 /pdbcompress /debugtype:pdata Release\Device.obj
  Release\Driver.obj
  Release\Queue.obj

But still run the SDV error.但是仍然运行SDV错误。

please help me to fix this.请帮我解决这个问题。 thanks.谢谢。

=========================================================================== ================================================ =========================

After I update to latest SDK, WDK to version 10.1.22000, and update visual studio 2019 and the error of the template driver gone away, but I facing other problem in my project in在我更新到最新的 SDK、WDK 到版本 10.1.22000 并更新 visual studio 2019 之后,模板驱动程序的错误消失了,但我在我的项目中遇到了其他问题

sdv/smvcl.log 

c1 : fatal error C1252: Circular or missing dependency between plugins: 'PREfast Drivers Plugin' requires GUID '{EB170136-3433-4C16-AE1D-8998BA5CAB16}'.

can anyone help me?谁能帮我?

Hi I had this problem (linker error on static driver verifier build) with WDK 10.0.22000 (with visual studio 2019) and here's the solution I've found: it links when the macro NT_PROCESSOR_GROUPS is defined at compile time (have to rebuild all), so adding this macro to the preprocessor definitions does the trick (at least for my setup).嗨,我在 WDK 10.0.22000(使用 visual studio 2019)中遇到了这个问题(static 驱动程序验证程序版本上的链接器错误),这是我找到的解决方案:它在编译时定义宏 NT_PROCESSOR_GROUPS 时链接(必须重建所有),所以将这个宏添加到预处理器定义中就可以了(至少对于我的设置而言)。

Just in case you are running across static driver verifier failures now or in the future, here is a useful hint:以防万一您现在或将来遇到 static 次驱动程序验证程序失败,这里有一个有用的提示:

Run SDV target with /debug enabled: so在启用 /debug 的情况下运行 SDV 目标:so

msbuild /t:sdv /p:Inputs="/check:* /debug" path\to\myproject.vcxproj /p:Configuration=Release /p:Platform=x64 /maxCpuCount=8

will create debug logs.将创建调试日志。 The output of the linker is found in the sdv subdirectory and is named smvlink1.log. linker中的output在sdv子目录下,命名为smvlink1.log。 There are other useful logfiles in that directory (took me a long time to find them but the output directed me to the solution I proposed above).该目录中还有其他有用的日志文件(我花了很长时间才找到它们,但 output 指导我找到了上面提出的解决方案)。

You're not alone in encountering problems with SDV in Visual Studio 2019. I ran into this with a mature driver after updating the tools and rebuilding.在 Visual Studio 2019 中遇到 SDV 问题的并不只有你一个人。我在更新工具和重建后使用成熟的驱动程序遇到了这个问题。 Fortunately, as is often the case, the good guys at OSR already ran headfirst into this wall themselves, and found a solution :幸运的是,通常情况下,OSR 的好人自己已经一头扎进了这堵墙,并找到了解决方案

It seems that if you try to run SDV on a driver project that has “Enable Code Analysis on Build” set to YES, SDV will always fail in the way you see illustrated above.看起来,如果您尝试在“在构建时启用代码分析”设置为“是”的驱动程序项目上运行 SDV,SDV 将始终以您在上文中看到的方式失败。 So, the fix is to disable Code Analysis on Build and be sure to save the project to disk.因此,解决方法是禁用构建时的代码分析,并确保将项目保存到磁盘。 Then run SDV.然后运行 SDV。

The driver I was working on did indeed have "Enable Code Analysis on Build" turned on.我正在处理的驱动程序确实打开了“在生成时启用代码分析”。 Turning it off allowed SDV to build it successfully.关闭它允许 SDV 成功构建它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM