compiling with winddk cl.exe

i have just started to cut my teeth with wdk (winddk 3790.1830)

i am at present trying only with commandline (no vc no ddkbuild
integration with vc etc)

is there any comprehensive list where by i can find what those
TARGETTYPE = macros mean (TARGETTYPE is juat an example)

i grepped through makedef.new to find a few like this

findstr /S “TARGETTYPE” *.new

== “DYNLINK”
== “DRIVER” || \
== “EXPORT_DRIVER” || \
== “HAL” || \
== “GDI_DRIVER”
== “DRIVER” || \
“EXPORT_DRIVER” || \
“MINIPORT” || \

i would like to know what each are and what associated entries they take

for example

if i set TARGETTYPE == PROGRAM
then what would UMENTRY be

where can i find if i have to put main , winmain , or _DllCrtStartup

where can find the /D (defines)

i just passed a command
C:\win32kpdb>cl.exe /Zi /Gz /c /Fdwin32k.pdb /I paths> /D_X86_=1 some.c

and in the some.c there are a few

UINT one;
UINT two;

which cl simply complains about saying unknown identifier
UINT

if i add a typedef

typedef unsigned int UINT;
cl compiles it happily

looking around i think i need to add /D_windef_=1

is that right ?

what else <define_names> exist ?
is grepping with findstr the only option to find out

i can open all the files in /src and learn a few things but
it would be helpful if some one can point out something
that has this all explained in a comprehensive list

also i went to msdn in search of /I for cl.exe
it states one can add multiple include paths with semicolon

but wdk cl.exe doesnt seem to accept ;

/I%DDK_INC_PATH%;%CRT_INC_PATH
doesnt seem to work

whereas sending them seperately like

/I%DDK_INC_PATH /I%CRT_INC_PATH% seems to work

sorry if the quetions seems to be too stupid

any pointers would be helpful</define_names>

TARGETTYPE and other macros are documented:
http://msdn2.microsoft.com/En-US/library/ms792396.aspx
WinDDK and WDK also include this documentation. Why didn’t you look there?

Instead of directly using the compiler, the Build utility is much more convenient:
http://msdn2.microsoft.com/en-us/library/ms792380.aspx

If this is your first encounter with WinDDK, I suggest building some of the samples to become familiar with the tools.

First you are using the DDK not the WDK. Consider moving up to the WDK
since the newer kit has newer and better tools.

As was pointed out all the standard stuff is documented in the WDK
documentation. Once you have worked through that if you need something
more, read the makefile.new but for the most part you do not need it.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“raj_r” wrote in message news:xxxxx@ntdev…
>i have just started to cut my teeth with wdk (winddk 3790.1830)
>
> i am at present trying only with commandline (no vc no ddkbuild
> integration with vc etc)
>
> is there any comprehensive list where by i can find what those
> TARGETTYPE = macros mean (TARGETTYPE is juat an example)
>
> i grepped through makedef.new to find a few like this
>
> findstr /S “TARGETTYPE” *.new
>
> == “DYNLINK”
> == “DRIVER” || <br>> == “EXPORT_DRIVER” || <br>> == “HAL” || <br>> == “GDI_DRIVER”
> == “DRIVER” || <br>> “EXPORT_DRIVER” || <br>> “MINIPORT” || <br>>
> i would like to know what each are and what associated entries they take
>
> for example
>
> if i set TARGETTYPE == PROGRAM
> then what would UMENTRY be
>
> where can i find if i have to put main , winmain , or DllCrtStartup
>
> where can find the /D (defines)
>
> i just passed a command
> C:\win32kpdb>cl.exe /Zi /Gz /c /Fdwin32k.pdb /I > paths> /D_X86
=1 some.c
>
> and in the some.c there are a few
>
> UINT one;
> UINT two;
>
> which cl simply complains about saying unknown identifier
> UINT
>
> if i add a typedef
>
> typedef unsigned int UINT;
> cl compiles it happily
>
> looking around i think i need to add /D_windef_=1
>
> is that right ?
>
> what else <define_names> exist ?
> is grepping with findstr the only option to find out
>
> i can open all the files in /src and learn a few things but
> it would be helpful if some one can point out something
> that has this all explained in a comprehensive list
>
> also i went to msdn in search of /I for cl.exe
> it states one can add multiple include paths with semicolon
>
> but wdk cl.exe doesnt seem to accept ;
>
> /I%DDK_INC_PATH%;%CRT_INC_PATH
> doesnt seem to work
>
> whereas sending them seperately like
>
> /I%DDK_INC_PATH /I%CRT_INC_PATH% seems to work
>
> sorry if the quetions seems to be too stupid
>
> any pointers would be helpful
></define_names>

Thanks AlyahDot,

yep i understand build is the preferred way
but i wanted to understand the backend better instead of simply copy pasting
and telling it to do build -cZ

for example if i am building a dll and an exe that calls into the exe
(both user mode)
how am i supposed to inform the build that the lib im linking against
is being built

i saw LINKLIBS macro
but before i saw LINKLIBS macro i made a few precomp.h
and created a dll and exe at one go

with this sourcefile

TARGETNAME=TestApp
TARGETTYPE=PROGRAM

SAMPLE_COMMON_DIR=D:\DDKTests

TARGETPATH=$(SAMPLE_COMMON_DIR)

UMENTRY=main

SOURCES=TestApp.c

TARGETLIBS=D:\DDKTests\i386\TestDll.lib

UMTYPE=console

PRECOMPILED_INCLUDE=precomp.h
PRECOMPILED_PCH=precomp.pch
PRECOMPILED_OBJ=precomp.obj

now that targetlibs macros path is not looking very portable to me
(it works in this specific instance coz i built the dll first found
where it is putting the lib and then i told it beforehand to look
there )

is this how it is built ?
or if the LINKLIBS macro give me some respite from doing this include
precomp.pch
thingy

i was looking for some article or tutorial

On 7/21/07, xxxxx@hushmail.com wrote:
> TARGETTYPE and other macros are documented:
> http://msdn2.microsoft.com/En-US/library/ms792396.aspx
> WinDDK and WDK also include this documentation. Why didn’t you look there?
>
> Instead of directly using the compiler, the Build utility is much more convenient:
> http://msdn2.microsoft.com/en-us/library/ms792380.aspx
>
> If this is your first encounter with WinDDK, I suggest building some of the samples to become familiar with the tools.
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

I would agree with Don that you don’t need this information to build
source, but I more than understand your wish to understand what is
actually going on. I think the easiest way to get the information you
are after is to build variety of samples from the WDK/SDK and examine
the logs. There you will find all of the compiler and linker switches,
unfortunately buried in some otherwise pretty useless stuff. If you
want to understand how a particular macro in SOURCES translates in to
some a /D statement, then, as Don said, you’ve got to look at
Makefile.New (I think that is the name). I would recommend doing this
after looking at the logs, as the logs are a much simpler place to
start.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of raj_r
Sent: Saturday, July 21, 2007 13:51
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] compiling with winddk cl.exe

Thanks AlyahDot,

yep i understand build is the preferred way
but i wanted to understand the backend better instead of simply copy
pasting
and telling it to do build -cZ

for example if i am building a dll and an exe that calls into the exe
(both user mode)
how am i supposed to inform the build that the lib im linking against
is being built

i saw LINKLIBS macro
but before i saw LINKLIBS macro i made a few precomp.h
and created a dll and exe at one go

with this sourcefile

TARGETNAME=TestApp
TARGETTYPE=PROGRAM

SAMPLE_COMMON_DIR=D:\DDKTests

TARGETPATH=$(SAMPLE_COMMON_DIR)

UMENTRY=main

SOURCES=TestApp.c

TARGETLIBS=D:\DDKTests\i386\TestDll.lib

UMTYPE=console

PRECOMPILED_INCLUDE=precomp.h
PRECOMPILED_PCH=precomp.pch
PRECOMPILED_OBJ=precomp.obj

now that targetlibs macros path is not looking very portable to me
(it works in this specific instance coz i built the dll first found
where it is putting the lib and then i told it beforehand to look
there )

is this how it is built ?
or if the LINKLIBS macro give me some respite from doing this include
precomp.pch
thingy

i was looking for some article or tutorial

On 7/21/07, xxxxx@hushmail.com wrote:
> TARGETTYPE and other macros are documented:
> http://msdn2.microsoft.com/En-US/library/ms792396.aspx
> WinDDK and WDK also include this documentation. Why didn’t you look
there?
>
> Instead of directly using the compiler, the Build utility is much more
convenient:
> http://msdn2.microsoft.com/en-us/library/ms792380.aspx
>
> If this is your first encounter with WinDDK, I suggest building some
of the samples to become familiar with the tools.
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> but i wanted to understand the backend better instead of simply copy pasting

and telling it to do build -cZ.

You don’t have to think too much about underlying compiler-related stuff when actually building a driver - instead, you have to worry about it when writing its SOURCES file, because everything that you have specified there ends up as a parameter to WDK compiler. Therefore, this is where your starting point lies - if you learn how to write a SOURCES file, you will automatically learn all underlying stuff that you want to know. Most of the stuff that you need to know when writing SOURCES files is documented in WDK, so first of all, read documentation, and then proceed to makefile.new (as it has been pointed out already, examining logs of builds before doing it is also quite helpfull) …

Anton Bassov

On 7/21/07, Don Burn wrote:
> First you are using the DDK not the WDK. Consider moving up to the WDK
> since the newer kit has newer and better tools.

yes i will consider moving to wdk but i was hoping the splitting of it
to manageable size happens soon (some thing to the effect that its
being split was posted on hectors memos some months ago but the last
time i checked it was still 2.3 gb )

On 7/22/07, Martin O’Brien wrote:
> I would agree with Don that you don’t need this information to build
> source, but I more than understand your wish to understand what is
> actually going on. I think the easiest way to get the information you
> are after is to build variety of samples from the WDK/SDK and examine
> the logs. There you will find all of the compiler and linker switches,
> unfortunately buried in some otherwise pretty useless stuff. If you

Thanks i will look into the build logs i was wondering if some one who
looked there already has made a documents of sorts like DDK for
Dummies, Learn DDK in 21 Ticks ,Source Macro In Micro Seconds, you
know the sort that of articles
all

On 7/22/07, xxxxx@hotmail.com wrote:
> > but i wanted to understand the backend better instead of simply copy pasting
> > and telling it to do build -cZ.
>
> You don’t have to think too much about underlying compiler-related stuff when actually building a driver - instead, you have to worry about it when writing its SOURCES file, because everything that you have specified there ends up as a parameter to WDK compiler. Therefore, this is where your starting point lies - if you learn how to write a SOURCES file, you will automatically learn all underlying stuff that you want to know.

yep looks like i have to dig them out myself thanks hopefully if i
succeed i plan to write a few
hello world from GDIDRIVER , hello world from DYNLINK hello world from HAL

regards

raj_r