Link to home
Start Free TrialLog in
Avatar of michelleyi
michelleyi

asked on

Compile error when build Win DDK printer sample code -- oemuni in MVC6

Hi,
I'm new in printer driver programming and want to learn through debugging through some printer sample codes in Win DDK. I crossed by BeyondWu's solution posted years ago regarding compile oemuni in MVC6, and following the instructions.

 And got following compiler errors:

--------------------Configuration: OEMUNI - Win32 Debug--------------------
c:\winddk\6001.18001\src\print\oemdll\oemuni\ddihook.cpp(56) : fatal error C1083: Cannot open precompiled header file: 'OEMUNI.pch': No such file or directory

My environment is: Win XP, WDK 6001.18001 and MVC6. I named the project "oemuni".
I notice that the sample code of "oemuni" has been changed in WDK 6001.18001,  since there's no "umode" subdirectory exist in this version.

Any idea how to fix it?
Thanks in advance!



I use the "oemuni" sample under ddk folder, please follow me;)
1. Create a New "Win32 Dynamic-Link Library "project.
2. Input a name(any string) into the "Project Name" edit box.
3. Press [OK], then select "a simple dll project", I think you also can select "an empty dll project", but I've tested it.
4. press [finish].
5. delete all files from the left project window.
6. copy all files from the "oemuni" subfolder into current project folder.
7. add all files into current project.(I assume you know how to do it).
8. open source.inc file.
9. if there is a line "PRECOMPILED_CXX=1", it means using precompile head.
10. select "xxx files" from the left workspace window.
11. press right button of mouse, in the popup menu, select "settings..." item.
12.select "C/C++" tab.
13.select "Precompiled Headers" from the "Category" comobox.
14.select "Use Precompiled Header file (.pch)". then input "precomp.h" in the "through header:" edit box.
15.press [OK].
16.from the sources.inc, there is a line:
C_DEFINES=$(C_DEFINES) -DKERNEL_MODE -D_UNICODE -DUNICODE -DOEMCOM
-DKERNEL_MODE means define "KERNEL_MODE"
so open the setting dialogbox again(refer item 10), then select "C/C++" tab, and select General from "Category" comobox, in the "Preprocessor definitions:" edit box, input all the symbol copy from the sources.inc.
these are "KERNEL_MODE,_UNICODE,UNICODE,OEMCOM,DEBUG,USERMODE_DRIVER"
the USERMODE_DRIVER comes from the file "sources" under the umode subfolder.
17.still in the "C/C++" tab, select the "Preprocessor" from the "Category" comobox, input your ddk's include dir into the "Aditional include directories:" edit box.
for me, it is "F:\WINDDK\inc"
18.there is a line "DLLBASE=0x70000000", so you need to open the setting dialogbox again, select "Link" tab. then select "Output" from the "Category" comobox, input the "0x70000000" into the "Base Address:" editbox.
19.there is also a def in the umode folder. so please add this file into your project.
20.for this sample, the "precomp.h" file is a precompiled header file, but for VC's IDE we need a .cpp to use it.
so please create a new .cpp file and insert the line "#include "precomp.h" into the cpp file, then add this cpp file into your project, then select the cpp file in the left workspce window, press right button, in the popup menu, select "setting..." item, select "Precompiled Headers:" from the "catagory" comobox, then select the "Create precompiled header ...", then input the "precomp.h" into the following "Through header" edit box.

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of michelleyi
michelleyi

ASKER

Hello DanRollins,
Thanks for your help. The setting you suggested does help get rid of the error. But now I got other compiling errors:
c:\winddk\6001.18001\inc\api\bcrypt.h(112) : error C2485: 'align' : unrecognized extended attribute
c:\winddk\6001.18001\inc\api\bcrypt.h(112) : error C2059: syntax error : '('
c:\winddk\6001.18001\inc\api\bcrypt.h(118) : error C2485: 'align' : unrecognized extended attribute
c:\winddk\6001.18001\inc\api\bcrypt.h(118) : error C2059: syntax error : '('

The following is code snippet from line 111 of bcrypt.h.
Do you think is the compiler verion of MVC++ 6 is too old to recognize the keyword of "pack" in #pragma?
It also complains:
c:\winddk\6001.18001\inc\api\wingdi.h(4341) : warning C4068: unknown pragma
and its corresponding code is:
#pragma deprecated (UpdateICMRegKeyA)

Thanks again for your help, and look forward to hear more advice from you,
MichelleYi
#pragma pack(push, BCRYPT_OBJECT_ALIGNMENT)
typedef BCRYPT_STRUCT_ALIGNMENT struct _BCRYPT_OID
{
    ULONG   cbOID;
    PUCHAR  pbOID;
} BCRYPT_OID;
 
typedef BCRYPT_STRUCT_ALIGNMENT struct _BCRYPT_OID_LIST
{
    ULONG       dwOIDCount;
    BCRYPT_OID  *pOIDs;
} BCRYPT_OID_LIST;

Open in new window

Hi,
I used MVS 2005 instead of MVC6, the above compile errors disappeared.

Thanks DanRollins for your help,
MichelleYi
Just a little "heads up" for future questions:
   What's the right grade to give?
   http://www.experts-exchange.com/help.jsp#hi403
In general, if a comment answers the question, then it's worth an A.  No big deal this time, but something to think about for the future.
-- Dan
Hello DanRollins,
I'm new in this site, so not that familiar the grading system. I have requested to change the grade, hope the grade will get adjust to A.
Thanks again for your help.

MichelleYi
Grade changed.
 
modus_operandi
EE Moderator