Microsoft KB Archive/320067

= PRB: LIBRARY Target Type Does Not Include Driver Headers =

Article ID: 320067

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Windows XP Driver Development Kit
 * Microsoft Windows XP Driver Development Kit

-



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.

