I want to create and use a DRIVER_LIBRARY. Note that this is to be a
statically linked library. Do I need to add special declarations on
functions that I intend to export?
Similarly, do I need to add any special declarations to the function
prototypes in the user code?
Thanks in advance,
Dennis

By the way, I've tried this out (without any special declarations), and the
linker kicks out an unresolved external symbol error for all the referenced
library functions.

Re: Using Libraries by Vetzak

Vetzak
Mon Nov 14 07:45:46 CST 2005


TARGETTYPE in the SOURCES file specifies what you want. Do you want to
create a .lib file or a kernel-mode DLL ? Anyway, to create a .lib:

TARGETTYPE=DRIVER_LIBRARY

To create a kernel-mode DLL a.k.a. export driver, specify:

TARGETTYPE=EXPORT_DRIVER


Re: Using Libraries by db_from_mn

db_from_mn
Mon Nov 14 07:58:53 CST 2005

Hello Vetzak,
Thanks for the response.
I understand how to build the static library and how to build the driver
that will use the library.
What I do not understand is whether I need to add special declarations in my
functions to export / import them.
Like a DLL, do I have to do someting like this?


extern "C" __declspec(dllexport) int fn(void){} (Function definition)


extern "C" __declspec(dllimport) int fn(void); (Function prototype)

Best regards,
Dennis

"Vetzak" <ptrshrn@gmail.com> wrote in message
news:1131975946.111583.302870@o13g2000cwo.googlegroups.com...
>
> TARGETTYPE in the SOURCES file specifies what you want. Do you want to
> create a .lib file or a kernel-mode DLL ? Anyway, to create a .lib:
>
> TARGETTYPE=DRIVER_LIBRARY
>
> To create a kernel-mode DLL a.k.a. export driver, specify:
>
> TARGETTYPE=EXPORT_DRIVER
>



Re: Using Libraries by Vetzak

Vetzak
Mon Nov 14 09:30:11 CST 2005


Calling conventions and import/export declarations are convered with
macros DECLSPEC_IMPORT and DECLSPEC_EXPORT. You have to create a .def
file as well.

There's information in the online MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/kmarch/hh/kmarch/Other_da2a8dc8-0d67-476c-8444-50ebb10ced96.xml.asp


Re: Using Libraries by Don

Don
Mon Nov 14 09:36:05 CST 2005

No, you should not be using __declspec(dllexport), a static library is just
a collection of .obj files and should act the same as listing the obj files
on the link line. Use dumpbin and see if the names in the library match the
names in your drivers objecxts.

"db_from_mn" <dburns@rtessentials.com> wrote in message
news:%23nsZOPS6FHA.2616@TK2MSFTNGP15.phx.gbl...
> Hello Vetzak,
> Thanks for the response.
> I understand how to build the static library and how to build the driver
> that will use the library.
> What I do not understand is whether I need to add special declarations in
> my functions to export / import them.
> Like a DLL, do I have to do someting like this?
>
>
> extern "C" __declspec(dllexport) int fn(void){} (Function definition)
>
>
> extern "C" __declspec(dllimport) int fn(void); (Function prototype)
>
> Best regards,
> Dennis
>
> "Vetzak" <ptrshrn@gmail.com> wrote in message
> news:1131975946.111583.302870@o13g2000cwo.googlegroups.com...
>>
>> TARGETTYPE in the SOURCES file specifies what you want. Do you want to
>> create a .lib file or a kernel-mode DLL ? Anyway, to create a .lib:
>>
>> TARGETTYPE=DRIVER_LIBRARY
>>
>> To create a kernel-mode DLL a.k.a. export driver, specify:
>>
>> TARGETTYPE=EXPORT_DRIVER
>>
>
>



Re: Using Libraries by Maxim

Maxim
Mon Nov 14 13:45:12 CST 2005

> I want to create and use a DRIVER_LIBRARY. Note that this is to be a
> statically linked library. Do I need to add special declarations on
> functions that I intend to export?

Create the .DEF file and list them there. The best way. All other ways give you
mangled names.

> Similarly, do I need to add any special declarations to the function
> prototypes in the user code?

.DEF file is better.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: Using Libraries by Maxim

Maxim
Mon Nov 14 13:46:52 CST 2005

> extern "C" __declspec(dllexport) int fn(void){} (Function definition)
>
>
> extern "C" __declspec(dllimport) int fn(void); (Function prototype)

This bad way will export the function with _MyMangledName@8 mangled name. Use
the .DEF file instead.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com