PRB: LIBRARY Target Type Does Not Include Driver Headers (320067)



The information in this article applies to:

  • Microsoft Windows XP Driver Development Kit (DDK)
  • Microsoft Windows .NET Driver Development Kit (DDK) BETA

This article was previously published under Q320067

SYMPTOMS

If you use the Windows XP or Windows .NET DDK to compile kernel-mode libraries by specifying the following in your SOURCES file

TARGETTYPE=LIBRARY

this may generate errors because of missing headers. This behavior is more evident when you compile sample libraries from the Microsoft Windows 2000 DDK, because samples in that particular DDK use the 'LIBRARY' TARGETTYPE directive and include kernel-mode-only headers.

CAUSE

This behavior occurs because the Windows XP and Windows .NET DDKs automatically set default include paths, which depend on the type of executable being built (such as EXE and DRIVER). However, when TARGETTYPE=LIBRARY is specified, the Windows XP and Windows .NET DDKs default to the inclusion of the %SDK_INC_PATH% only, and do not automatically include the %DDK_INC_PATH% or %WDM_INC_PATH%. This is because the library is assumed to be a user-mode library.

RESOLUTION

If the current TARGETTYPE is LIBRARY, and kernel includes are needed, use one of the following methods, as appropriate to your situation:
  • If your code is user-mode-oriented, update the INCLUDES.

    -or-
  • If your code is kernel-mode-oriented, revise the TARGETTYPE value to DRIVER_LIBRARY.

STATUS

This behavior is by design.

MORE INFORMATION

TARGETTYPE=LIBRARY builds a user-mode library. If you need kernel includes, update your INCLUDES path to include %DDK_INC_PATH% or %WDM_INC_PATH%, as necessary.

TARGETTYPE=DRIVER_LIBRARY builds a kernel-mode library. Kernel headers are included by default. This is almost the same as TARGETTYPE=LIBRARY. The differences include the following:
  • %DDK_INC_PATH% and %WDM_INC_PATH% are used.

    -and-
  • The -cbstring compiler option is used.
TARGETTYPE=DYNLINK is used for building dynamic link libraries. If you need kernel includes, set INCLUDES in your sources file, because they are not included by default. This is not intended for use with kernel-mode code.

REFERENCES

See the relevant DDK for more information about the build environment and the aforementioned environment variables.

Modification Type:MinorLast Reviewed:7/22/2004
Keywords:kbKMode kbprb KB320067