Problem importing .lib into VS

Hello all!

We are developing a minifilter driver and supporting API library to
communicate with the minifilter. API library is of TARGETTYPE DYNLINK thus
producing .dll, .lib and .exp files. Interfaces to be exported are listed
in .def file.

We use WinDDK 5308 (and 5600) to build three projects: minifilter driver,
API import library and user space application using import library. All is
working fine as long as we use build tool from WinDDK. But when we try to
compile user space application in VS 2003 (or VS 2005) against import
library built with WinDDK we get “unresolved external symbol” calling our
exported API interface.

We tried to investigate the problem and resolved to be a linker problem. It
seems that import library .lib made with WinDDK build tool is incompatible
with VS 2003. First we build API as usual with WinDDK build tool. Then we
recreate import library with link.exe from VS 2003. Generated .lib and
.exp work as expected and are successfully imported and used when linking
user space application.

As already said we tried all combinations of WinDDK 5308, WinDDK 5600, VS
2003 and VS 2005 with no success. Is there are known solution to this
problem or should we compile API library with VS?

Thank you for any tips,

Klemen Vodopivec

Did you try using the depends tool to see what exactly was undefined?

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@vodopivec.org
Sent: Wednesday, September 27, 2006 5:07 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem importing .lib into VS

Hello all!

We are developing a minifilter driver and supporting API
library to communicate with the minifilter. API library is of
TARGETTYPE DYNLINK thus producing .dll, .lib and .exp files.
Interfaces to be exported are listed in .def file.

We use WinDDK 5308 (and 5600) to build three projects:
minifilter driver, API import library and user space
application using import library. All is working fine as long
as we use build tool from WinDDK. But when we try to compile
user space application in VS 2003 (or VS 2005) against import
library built with WinDDK we get “unresolved external symbol”
calling our exported API interface.

We tried to investigate the problem and resolved to be a
linker problem. It seems that import library .lib made with
WinDDK build tool is incompatible with VS 2003. First we
build API as usual with WinDDK build tool. Then we recreate
import library with link.exe from VS 2003. Generated .lib and
.exp work as expected and are successfully imported and used
when linking user space application.

As already said we tried all combinations of WinDDK 5308,
WinDDK 5600, VS
2003 and VS 2005 with no success. Is there are known solution
to this problem or should we compile API library with VS?

Thank you for any tips,

Klemen Vodopivec


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

To reply my own question (maybe someone else finds it usable)…

DDK build tool uses /Gz switch by default (__stdcall calling convention) while VS uses /Gd. Forcing DDK to use /Gd solved my problem.

Btw: We used 386_STDCALL=0 for the purpose which is not documented in DDK documentation.

An alternative is to make your library calling convention explicit rather
than relying on the default settings for your build tools.

So for example all of my ddk build user mode libraries have function
declarations like this:

#ifdef __cplusplus
extern “C”
#endif
HRESULT
__cdecl
xxxOpenPort(OUT HANDLE * Port );

And consequently I do not have to fiddle with ddk build settings or vs build
settings.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@vodopivec.org
Sent: Wednesday, September 27, 2006 8:25 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problem importing .lib into VS

To reply my own question (maybe someone else finds it usable)…

DDK build tool uses /Gz switch by default (__stdcall calling
convention) while VS uses /Gd. Forcing DDK to use /Gd solved
my problem.

Btw: We used 386_STDCALL=0 for the purpose which is not
documented in DDK documentation.


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

> We use WinDDK 5308 (and 5600) to build three projects: minifilter driver,

API import library and user space application using import library. All is
working fine as long as we use build tool from WinDDK. But when we try to
compile user space application in VS 2003 (or VS 2005) against import
library built with WinDDK we get “unresolved external symbol” calling our
exported API interface.

Do not forget to explicitly declare all our DLL exports as “__stdcall” in the
header file. The thing is that DDK defaults to stdcall calling convention, and
VS defaults to cdecl.

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