Re: LINK error

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




Thanks for your quick response. Just to do a workaround with the header file
as you suggested , i did the following way
I defined two MACROs
#define DLLEXPORT __declspec(dllexport)
#define DLLCALL __stdcall

I changed the header files declaration as
DLLEXPORT retvalue DLLCALL func();
It did not help me. The linker complains with the LNK2019 error(unresolved
external symbol).

But when i changed the DLLCALL to __cdecl, it compiled with out an error in
WINDDK, but when i run the application an error window poped up, and says
"...It is not a valid win32 application".
Any idea...


"Maxim S. Shatskih" wrote:

1. Is it possible to link the 3rd party library to my DDK application?

If it is built with GNU make - then it is probably open-source, in which case I would rework its source/build scripts so it will also be buildable with WDK.

Building closed-source Windows code with non-Microsoft tools is a very bad idea from the LIB vendor.

Cross-linking between different build tools can have issues. Calling convention is one of the most major of them. Look at the .H file for the LIB. Are the functions declared explicitly with __stdcall or with __cdedl? they should be. This is, BTW, even the issue between Visual Studio (__cdecl default) and WDK (__stdcall default).

C++ can add another can of worms there, a huge one, this is not only about the name mangling, but also about the vmtable/vbtable layout and runtime support for exceptions and RTTI.

So:
- if there is the source - build it using WDK too, avoid GNU tools at all
- if there is no source and this is C, not C++ - look at calling convention, there is a good probability it will be enough for the things to work
- if there is no source and this is C++ - you're probably hosed completely.

--
Maxim S. Shatskih
Windows DDK MVP
maxim@xxxxxxxxxxxxxxxx
http://www.storagecraft.com


.



Relevant Pages

  • Re: LINK error
    ... Just to do a workaround with the header file ... DLLEXPORT retvalue DLLCALL func; ... Building closed-source Windows code with non-Microsoft tools is a very bad idea from the LIB vendor. ... if there is the source - build it using WDK too, avoid GNU tools at all ...
    (microsoft.public.development.device.drivers)
  • HIDE 1.0.7 now available for HLA
    ... which uses the wscan.exe program to extract windows constants and external declarations from the w.hhf header file to create a more compact version to include in programs. ... This is an early experimental version which requires some manual work to get all the symbols referenced indireclty through the windows header file. ... -option to auto-complete common HLA structure keywords -1 click/key jump to declarations -debug mode and debug window to display output. ...
    (alt.lang.asm)
  • GetLocalPathName could not be located in Kernel32.dll
    ... Apparently this function is not implemented in Windows NT 4. ... Include an additional header file ... But now I am getting the following error during compilation: ... a C-style cast or ...
    (microsoft.public.dotnet.languages.vc)
  • RE: SSL and CrytoAPI
    ... Common header file containing handy macros and definitions ... this version has been modified to use GetWindowLong instead of ... Minimum operating systems Windows 95, ... Unicode Implemented as Unicode and ANSI versions on Windows NT, Windows 2000, Windows XP ...
    (microsoft.public.platformsdk.security)