• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2083
  • Last Modified:

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

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:
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.
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

  • 3
  • 2
1 Solution
In project / settings / C/C++ / (Catagory:  Precompiled headers)
choose Automatic use of precompikled headers.
michelleyiAuthor Commented:
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,
#pragma pack(push, BCRYPT_OBJECT_ALIGNMENT)
    ULONG   cbOID;
    PUCHAR  pbOID;
    ULONG       dwOIDCount;

Open in new window

michelleyiAuthor Commented:
I used MVS 2005 instead of MVC6, the above compile errors disappeared.

Thanks DanRollins for your help,
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Just a little "heads up" for future questions:
   What's the right grade to give?
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
michelleyiAuthor Commented:
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.

Grade changed.
EE Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now