Search code examples
c++windowsmakefilewdk

Add dependency on Shell32.lib to WDK makefile


I've successfully powered my way through the WDK XPSDrv sample project and modified it to do what I need. However, I absolutely cannot figure out how to get the build scripts to reference/include/whatever shell32.lib. I'm a .NET guy! This is strange and terrifying territory.

I think adding a dependency reference is what I need to do. When I compile I get this error

3>errors in directory c:\winddk\7600.16385.1\src\printgit\xpsdrvsmpl\
src\filters\common
3>c:\winddk\7600.16385.1\src\printgit\xpsdrvsmpl\src\filters\common\
xdstrmflt.cpp(238) : error C3861: 'ShellExecute': identifier not found

Due to my extreme lack of knowledge (and hurry) I'm not using visual studio, just simple mods in notepad++ and the shell wdk build environment. I have a surrogate project in VS where I've been writing and testing small chunks of code. In that project I added a Dependency library to shell32.lib and everything worked perfectly.

There's a makefile that references a sources, the contents are below.

Not that it matters, but the code that requires shell32 is

HINSTANCE statu = ShellExecute(NULL,TEXT("open"),szTempFileName,NULL,NULL,9);

Here's the sources file.

INCLUDES=$(INCLUDES);        \
    .\;                      \
    .\..\inc;                \
    .\..\debug;              \
    $(DDK_INC_PATH);         \
    $(SDK_INC_PATH)\gdiplus; \

USE_ATL=1
USE_STL=1

ATL_VER=70
STL_VER=70

# We use STL 7.0, which is not available pre-Vista. We therefore set USE_LIBCMT=1
# If STL 7.0 is not necessary, USE_MSVCRT=1 is recommended
USE_LIBCMT=1

USE_IDLBASED_DLLDATA=1
USE_OBJECT_ROOT=1

MSC_WARNING_LEVEL=/W4 /WX

USE_NATIVE_EH=1

PRECOMPILED_CXX=1
PRECOMPILED_INCLUDE=precomp.h

# To remove debug code remove -DDBG from the line below
C_DEFINES=$(C_DEFINES) -D_UNICODE -DUNICODE

SOURCES=\
    bkpchndlr.cpp       \
    bkpthndlr.cpp       \
    bkschema.cpp        \
    cmpthndlr.cpp       \
    cmprofpthndlr.cpp   \
    cmprofpchndlr.cpp   \
    cmintpthndlr.cpp    \
    cmschema.cpp        \
    cmprofileschema.cpp \
    cmintentsschema.cpp \
    globals.cpp         \
    nupschema.cpp       \
    nupchndlr.cpp       \
    nupthndlr.cpp       \
    pchndlr.cpp         \
    pgscpchndlr.cpp     \
    pgscpthndlr.cpp     \
    pgscschema.cpp      \
    porientpthndlr.cpp  \
    porientschema.cpp   \
    psizepthndlr.cpp    \
    psizeschema.cpp     \
    pimagepthndlr.cpp   \
    pimageschema.cpp    \
    pshndlr.cpp         \
    pthndlr.cpp         \
    ptquerybld.cpp      \
    schema.cpp          \
    wmpchndlr.cpp       \
    wmpthndlr.cpp       \
    wmschema.cpp        \
    workbuff.cpp

TARGETNAME=xdsmplcmn
TARGETTYPE=LIBRARY

Solution

  • For example in your sources file:

    TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib $(SDK_LIB_PATH)\user32.lib $(SDK_LIB_PATH)\shell32.lib
    

    ... amend as needed ;)

    However, your error is actually not a linker error but a compiler error, so you'll likely want to include the header that declares ShellExecute, which is shellapi.h, in some way.


    Just looked the sample up in my WDK (7600.16385.1) and as a matter of fact you removed the very important part reproduced below, to which you just would have to append the other .lib files to link against:

    TARGETLIBS=                                  \
        $(SDK_LIB_PATH)\kernel32.lib             \
        $(SDK_LIB_PATH)\user32.lib               \
        $(SDK_LIB_PATH)\winspool.lib             \
        $(SDK_LIB_PATH)\ole32.lib                \
        $(SDK_LIB_PATH)\oleaut32.lib             \
        $(SDK_LIB_PATH)\advapi32.lib             \
        $(SDK_LIB_PATH)\msxml6.lib               \
        $(SDK_LIB_PATH)\uuid.lib                 \
        $(SDK_LIB_PATH)\Comdlg32.lib             \
        $(OBJ_PATH)\..\debug\$O\xdsdbg.lib \
        $(OBJ_PATH)\..\common\$O\xdsmplcmn.lib \
    

    ... apologies, there are plenty of sources files as part of this sample, so of course I cannot really know which of the samples you modified and are trying to build :)