none
error LNK2001: unresolved external symbol _WdfFunctions RRS feed

  • Question

  • I installed VS2015 then installed WDK(Win10). These is a error as below when use VS2015 to create a KMDF driver.

    1>  Generating Code...
    1>Device.obj : error LNK2001: unresolved external symbol _WdfFunctions
    1>Driver.obj : error LNK2001: unresolved external symbol _WdfFunctions
    1>Queue.obj : error LNK2001: unresolved external symbol _WdfFunctions
    1>D:\VSProject\KMDF Driver1\Debug\KMDFDriver1.sys : fatal error LNK1120: 1 unresolved externals

    How to fix it? Thanks.

    Thursday, March 23, 2017 3:52 AM

All replies

  • how did you create the KMDF driver project? file -> new -> Empty KMDF project? or did you create an empty project a different way? when you create an empty KMDF project it will automatically link against wdfstubs.lib which will contain this symbol

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, March 23, 2017 4:40 AM
  • I cteate the project by New Project->Windows Driver->WDF->Kernel Mode Driver(KMDF). How to fix it?
    Thursday, March 23, 2017 5:38 AM
  • Hi Doron,

    I reinstall VS, SDK and WDK, but can't fix this issue. Could you give some comments. Thanks.

    Thursday, March 23, 2017 9:23 AM
  • I am seeing the same error here in some previous project, but I think it should be able to be fixed by adding wdfstub.lib when linking.

    Would you please provide the full path of wdfstubs.lib? It is because I couldn't find it in C:\Program Files (x86)\Windows Kits\10\Lib

    Thursday, April 13, 2017 5:49 AM
  • Andy, Winfred. This is not an issue we have seen during testing. Andy you simply instantiate the standard KMDF template and then hit this issue during build? Would you please open a command prompt and run: cd / d "C:\Program Files (x86)\Windows Kits" dir /s /b wdfstubs.lib
    Thursday, April 13, 2017 9:53 AM
  • Hi Jakob,

    Please reference the following

    C:\Program Files (x86)\Windows Kits>dir /s /b wdfstubs.lib
    File Not Found

    C:\Program Files (x86)\Windows Kits>dir/w
     Volume in drive C is OSDisk
     Volume Serial Number is 6267-CC4B

     Directory of C:\Program Files (x86)\Windows Kits

    [.]        [..]       [10]       [8.0]      [8.1]      [NETFXSDK]
                   0 File(s)              0 bytes
                   6 Dir(s)  79,147,085,824 bytes free

    Friday, April 14, 2017 4:55 AM
  • Hi Winfred.  For me the KMDF template links fine.  But apparently not for you. 

    Let's compare your and my link commands.  Here is my link command (that I grabbed from output of 'msbuild /t:rebuild' and that succeeds):

    ++

    Link:
      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\jakobl\Document
      s\Visual Studio 2015\Projects\KMDF Driver11\KMDF Driver11\Debug\KMDFDriver11.sys" /VERSION:"10.0" /INCREMENTAL:NO /NO
      LOGO /WX /SECTION:"INIT,d" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.15063.0\km\x86\\cfg_support_v1.lib" "C:\P
      rogram Files (x86)\Windows Kits\10\lib\10.0.15063.0\km\x86\BufferOverflowFastFailK.lib" "C:\Program Files (x86)\Windo
      ws Kits\10\lib\10.0.15063.0\km\x86\ntoskrnl.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.15063.0\km\x86\hal.
      lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.15063.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.li
      b" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.15063.0\km\x86\wpprecorder.lib" /NODEFAULTLIB /MANIFEST:NO /DEBUG
       /PDB:"C:\Users\jakobl\Documents\Visual Studio 2015\Projects\KMDF Driver11\KMDF Driver11\Debug\KMDFDriver11.pdb" /SUB
      SYSTEM:NATIVE,"10.00" /Driver /OPT:REF /OPT:ICF /ENTRY:"FxDriverEntry@8" /RELEASE /IMPLIB:"C:\Users\jakobl\Documents\
      Visual Studio 2015\Projects\KMDF Driver11\KMDF Driver11\Debug\KMDFDriver11.lib" /MERGE:"_TEXT=.text;_PAGE=PAGE" /MACH
      INE:X86 /PROFILE /kernel /IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221 /osversion:10.0 /pdbcompress /debu
      gtype:pdata Debug\Device.obj
      Debug\Driver.obj
      Debug\Queue.obj

    ++

    Friday, April 14, 2017 5:14 AM
  • Hi Jakob,

    It shows no differences about the libraries to be linked. Only that I am using RS1 WDK and you're using RS2.

    Here is the link command output of the failing project, grabbed from the msbuild command prompt:

    Link:
      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe
      /ERRORREPORT:QUEUE
      /OUT:"C:\blah\blah.sys"
      /VERSION:"10.0" /INCREMENTAL:NO /NOLOGO /WX /SECTION:"INIT,d"
      "C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\km\x86\\cfg_support_v1.lib"
      "C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\km\x86\BufferOverflowFastFailK.lib"
      "C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\km\x86\ntoskrnl.lib"
      "C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\km\x86\hal.lib"
      "C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.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"
      /NODEFAULTLIB /MANIFEST:NO /DEBUG
      /PDB:"C:\blah\blah.pdb"
      /SUBSYSTEM:NATIVE,"10.00" /Driver /OPT:REF /OPT:ICF /ENTRY:"FxDriverEntry@8" /RELEASE
      /IMPLIB:"C:\blah\Win10Debug\blah.lib"
      /MERGE:"_TEXT=.text;_PAGE=PAGE" /MACHINE:X86 /PROFILE /kernel
      /IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221
      /osversion:10.0 /pdbcompress /debugtype:pdata Win10Debug\blah.res
      Win10Debug\blah.obj
      xxx\xxx.lib
      yyy\yyy.lib
      ...
      xxx.lib(xxx.obj) : error LNK2019: unresolved external symbol _WdfFunctions referenced in function _xxxx@8
      yyy.lib(yyy.obj) : error LNK2001: unresolved external symbol _WdfFunctions
      zzz.lib(zzz.obj) : error LNK2001: unresolved external symbol _WdfFunctions
      ...
    
    Tuesday, April 18, 2017 3:47 AM
  • OK. I am not quite sure what next step would be to get a repro of your problem.  Would you be open to try to move to RS2 WDK?

    Tuesday, April 18, 2017 3:50 AM
  • Hi!

    I am getting the same problem. I am building on Windows 10 Enterprise Build 1607, targeting the driver to WDK v10.0.14393.0. Running on Visual Studio 2015 Update 3 and Windows SDK 8.1 and 10 installed, as well as WDK for 1607 installed. There is NO file wdfstubs.lib in the C:\ drive in my development system. Did any of you get a proper solution to this?

    Thanks

    R A

    Friday, June 30, 2017 5:03 AM
  • I don't know where Jakob came up with that name, but it's not right.  The correct libraries are wdfdriverentry.lib and wdfldr.lib.  If you have selected a KMDF driver type, the template should add those on your behalf.

    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    Friday, June 30, 2017 9:09 PM
  • Purely informational, wdfstubs is the internal script that creates the wdffunctions jump table that is a part of wdfdriverentry.lib

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Saturday, July 1, 2017 3:14 AM