none
How to Create and Use static library file in KMDF drivers RRS feed

  • Question

  • Hi experts...

    My ultimate goal is to create a .lib file for the kernel mode driver and to use that .lib in my project

    I have tried to create static library file for the windows driver with the header.h and the functions are defined in .c

    I use visual studio 2013 with WDK 8.1 environment

    I have goggled about it and managed to create a .lib file through empty static library for driver as new project and add my headers and c files and build it successfully.

    but i am not sure I have followed correct procedures please note me if I am wrong.

    Then i have linked the header file and the .lib file to my project through properties and tried to use the functions in my project but got link errors.

    I able manage .lib file create and add in win32 environment and use it in win32 console project, but it didn’t help me for my driver project and mostly got diverted to DLL and win32 console.

    Please provide me some link that I can able to get details about the .lib file create in kernel mode driver (KMDF) and how can I add it to the project

    And tried to link the lib file created with the KMDF driver but its showing link errors like

    Error      1              error MSB6006: "link.exe" exited with code 1120.

    Error      2              error LNK2001: unresolved external symbol _RTC_InitBase

    Error      3              error LNK2001: unresolved external symbol _RTC_Shutdown

    Error      4              error LNK1120: 2 unresolved externals

    Thursday, August 27, 2015 11:09 AM

Answers

  • For creating a static library make a KMDF driver project then go into the properties and change the type to static library.  This approach should save the settings for the driver.  The _RTC_* symbols are part of the user space runtime environment and not present in the kernel.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    • Marked as answer by Rajganesh006 Thursday, August 27, 2015 1:18 PM
    Thursday, August 27, 2015 11:39 AM

All replies

  • For creating a static library make a KMDF driver project then go into the properties and change the type to static library.  This approach should save the settings for the driver.  The _RTC_* symbols are part of the user space runtime environment and not present in the kernel.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    • Marked as answer by Rajganesh006 Thursday, August 27, 2015 1:18 PM
    Thursday, August 27, 2015 11:39 AM
  • Thanks Don for quick reply and sharing valuable information

    It worked for me and also tried with Empty static library for driver project create and linked with my KMDF project its through me a error as .lib not build as kernel, so i added /kernel in command line under c/c++ properties in static library project and it also worked.

    whether it is also a correct way to build .lib file for KMDF driver

    Thursday, August 27, 2015 1:30 PM
  • Hi Don,

    I am working on a similar problem. I have created a kmdf library and trying to use the functions defined in the library in my driver code. I get the following link time error:

    error LNK2001: unresolved external symbol WdfFunctions_01015.

    I have defined my library as a static library. Do I need to modify any other project settings?

    Thanks

    Monday, December 28, 2015 1:07 AM
  • Are you building the driver with the same version of WDF as you built your library?  WdfFunctions_01015 is defined wdfdriverentry.lib but as you should note, the version 01015 is part of the name.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Monday, December 28, 2015 5:40 PM