DDK Linker error question

Hello,

I have been trying to get a simple driver with some standard string
processing functions to compile, but I am running into linker errors. From
what I could gather most of the string processing functions I need are in
libcntpr.lib and that I should link with that. When I compile I get the
following linker errors (cleaned up the paths):

1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isupper already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _islower already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isdigit already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isxdigit already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isspace already
defined in ntoskrnl.lib(ntoskrnl.exe)

My sources file is as follows:
TARGETNAME=SomeTest
TARGETPATH=obj
TARGETTYPE=DRIVER

USE_LIBCNTPR=1
TARGETLIBS=$(DDK_LIB_PATH)\libcntpr.lib

!IFNDEF MSC_WARNING_LEVEL
MSC_WARNING_LEVEL=/W3
!ENDIF

MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX

INCLUDES=…..;…..\includes;$(DDK_INC_PATH)

SOURCES=… # Long list of files…

Someone mentioned somewhere that this could be due to the order of the
include’s of the headers, but as unlikely as that seemed to me I tried it
and it didn’t work. When I change the TARGETTYPE to be a GDI_DRIVER
everything is nice and dandy, but I do need ntoskrnl.

Thanks,
Daniel

Tried USE_LIBCNTPR=1 instead of linking directly?


Aram Hăvărneanu

AFAIK LIBCNTPR is a usermode library only. That is likely why you felt
it necessary to add both

USE_LIBCNTPR=1

-and-

TARGETLIBS=$(DDK_LIB_PATH)\libcntpr.lib

because you added the USE_… and nothing happened ? which was correct.

So, why do you want to use functions that you think you can get from
LIBCNTPR in a kernel mode module? And what are you trying to accomplish?
Maybe we can help you with that directly.

Good Luck,

Dave Cattley

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Daniel Brodie
Sent: Sunday, September 26, 2010 7:38 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] DDK Linker error question

Hello,

I have been trying to get a simple driver with some standard string
processing functions to compile, but I am running into linker errors. From
what I could gather most of the string processing functions I need are in
libcntpr.lib and that I should link with that. When I compile I get the
following linker errors (cleaned up the paths):

1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isupper already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _islower already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isdigit already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isxdigit already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isspace already
defined in ntoskrnl.lib(ntoskrnl.exe)

My sources file is as follows:
TARGETNAME=SomeTest
TARGETPATH=obj
TARGETTYPE=DRIVER

USE_LIBCNTPR=1
TARGETLIBS=$(DDK_LIB_PATH)\libcntpr.lib

!IFNDEF MSC_WARNING_LEVEL
MSC_WARNING_LEVEL=/W3
!ENDIF

MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX

INCLUDES=…..;…..\includes;$(DDK_INC_PATH)

SOURCES=… # Long list of files…

Someone mentioned somewhere that this could be due to the order of the
include’s of the headers, but as unlikely as that seemed to me I tried it
and it didn’t work. When I change the TARGETTYPE to be a GDI_DRIVER
everything is nice and dandy, but I do need ntoskrnl.

Thanks,
Daniel

— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Ok, I should pay more attention before I jump in. I am not really up to
date on what all is happening with printer drivers as they vacillate between
UM, KM, back to UM, and who all knows what next. So I can see where the use
of LIBCNTPR could get confused. It may well be a KM library. No clue at
this point.

And I should read the DOCs instead of just MAKEFILE.NEW. The DOC clearly
say that setting USE_LIBCNTPR=1 enables ?kernel run-time libraries?.

So, ignore the network guy. He should know better and now he does.

Appologies all.

Dave Cattley

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David R. Cattley
Sent: Sunday, September 26, 2010 10:03 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] DDK Linker error question

AFAIK LIBCNTPR is a usermode library only. That is likely why you felt
it necessary to add both

USE_LIBCNTPR=1

-and-

TARGETLIBS=$(DDK_LIB_PATH)\libcntpr.lib

because you added the USE_… and nothing happened ? which was correct.

So, why do you want to use functions that you think you can get from
LIBCNTPR in a kernel mode module? And what are you trying to accomplish?
Maybe we can help you with that directly.

Good Luck,

Dave Cattley

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Daniel Brodie
Sent: Sunday, September 26, 2010 7:38 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] DDK Linker error question

Hello,

I have been trying to get a simple driver with some standard string
processing functions to compile, but I am running into linker errors. From
what I could gather most of the string processing functions I need are in
libcntpr.lib and that I should link with that. When I compile I get the
following linker errors (cleaned up the paths):

1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isupper already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _islower already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isdigit already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isxdigit already
defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isspace already
defined in ntoskrnl.lib(ntoskrnl.exe)

My sources file is as follows:
TARGETNAME=SomeTest
TARGETPATH=obj
TARGETTYPE=DRIVER

USE_LIBCNTPR=1
TARGETLIBS=$(DDK_LIB_PATH)\libcntpr.lib

!IFNDEF MSC_WARNING_LEVEL
MSC_WARNING_LEVEL=/W3
!ENDIF

MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX

INCLUDES=…..;…..\includes;$(DDK_INC_PATH)

SOURCES=… # Long list of files…

Someone mentioned somewhere that this could be due to the order of the
include’s of the headers, but as unlikely as that seemed to me I tried it
and it didn’t work. When I change the TARGETTYPE to be a GDI_DRIVER
everything is nice and dandy, but I do need ntoskrnl.

Thanks,
Daniel

— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

Libcntpr is the km (subset of the) crt. Not all of the crt is exported by ntos. What is the linker cmd line from the log file when you specify gdi_driver? My guess is that you are linking againat msvcrt.dll.

d

dent from a phpne with no keynoard


From: David R. Cattley
Sent: September 26, 2010 7:05 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] DDK Linker error question

AFAIK LIBCNTPR is a usermode library only. That is likely why you felt it necessary to add both

USE_LIBCNTPR=1

-and-
TARGETLIBS=$(DDK_LIB_PATH)\libcntpr.lib

because you added the USE_… and nothing happened ? which was correct.

So, why do you want to use functions that you think you can get from LIBCNTPR in a kernel mode module? And what are you trying to accomplish? Maybe we can help you with that directly.

Good Luck,
Dave Cattley

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Daniel Brodie
Sent: Sunday, September 26, 2010 7:38 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] DDK Linker error question

Hello,

I have been trying to get a simple driver with some standard string processing functions to compile, but I am running into linker errors. From what I could gather most of the string processing functions I need are in libcntpr.lib and that I should link with that. When I compile I get the following linker errors (cleaned up the paths):

1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isupper already defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _islower already defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isdigit already defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isxdigit already defined in ntoskrnl.lib(ntoskrnl.exe)
1>…\win32k\libcntpr.lib(_ctype.obj) : error LNK2005: _isspace already defined in ntoskrnl.lib(ntoskrnl.exe)

My sources file is as follows:
TARGETNAME=SomeTest
TARGETPATH=obj
TARGETTYPE=DRIVER

USE_LIBCNTPR=1
TARGETLIBS=$(DDK_LIB_PATH)\libcntpr.lib

!IFNDEF MSC_WARNING_LEVEL
MSC_WARNING_LEVEL=/W3
!ENDIF

MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX

INCLUDES=…..;…..\includes;$(DDK_INC_PATH)

SOURCES=… # Long list of files…

Someone mentioned somewhere that this could be due to the order of the include’s of the headers, but as unlikely as that seemed to me I tried it and it didn’t work. When I change the TARGETTYPE to be a GDI_DRIVER everything is nice and dandy, but I do need ntoskrnl.

Thanks,
Daniel
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

Basically, what I am trying to do is to get some logic chunk to work inside some wrapper driver. Some of this logic uses some string parsing functions. I would prefer to use existing functions then need to recreate them myself.

Here is the logfile of the GDI_DRIVER target that worked (I obviously had to add the relevant entry point):
http://pastebin.com/raw.php?i=wur9jTbv

Here is the logfile of the DRIVER target without specifying the lib directly with TARGETLIBS, as you can see it doesn’t actually link in libcntpr.lib and so doesn’t work:
http://pastebin.com/raw.php?i=xRNx0qmv

Here is the logfie of the DRIVER target with specifying the file directly in the TARGETLIBS, and the same error as in my first posting:
http://pastebin.com/raw.php?i=mkENZMZi
As you can see no msvcrt to be seen.

I would really not want to have to go and put in my own string handling functions, but as a last resort I might end up doing.

Thanks, guys, for your help,
Daniel