'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). 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.
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:
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
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
%(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.
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
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?
Solution 1:[1]
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).
Just in case you are running across static driver verifier failures now or in the future, here is a useful hint:
Run SDV target with /debug enabled: 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 . 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).
Solution 2:[2]
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. Fortunately, as is often the case, the good guys at OSR already ran headfirst into this wall themselves, and found a solution:
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. So, the fix is to disable Code Analysis on Build and be sure to save the project to disk. Then run 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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Johannes Thoma |
Solution 2 | Dave Ruske |