You definitely need the header file.
If you still have the problem, it means the definitions in the header don't specify the calling convention.
The general approach to handle linke errors:
Dump the functions used by your application
dumpbin /symbols
Dump the library and and the dll
dumpbin /exports
dumpbin /exports
For static libraries
dumpbin /symbols <libraryFileName.lib>
Find the function names in the 2 dumps (3 for the dll+import library)
and make sure they are identical.
Any mismatch you find will indicate what your problem is
Change your call to end up with the same result as the exported stuff
Interpreting (some of) the results:
C functions:
_functionName = C function, __cdecl calling convention
_functionName@12 = C function, __stdcall calling convention
@functionName@12 = C function, __fastcall calling convention
(of course, the number does not have to be 12)
C++ functions
They look like ?functionName@
That is the decorated name.
But the dump also contains the undecorated one.
Examples:
?functionName@@$$J0YMHHPADPAUKeyVal@@@Z
(extern "C" int __clrcall functionName(int,char *,struct KeyVal *))
=> you have all the info, including the fact that this is compiled to
managed code (__clrcall)
?functionName@@YAHHPADPAUKeyVal@@@Z
(int __cdecl functionName(int,char *,struct KeyVal *))
=> normal C++ function
?functionName@className@@QAEHHPADPAUKeyVal@@@Z
(public: int __thiscall className::functionName(int,char *,struct KeyVal
*))
=> member function (because of __thiscall) of the class className
And so on.
Tip: I recomand dump into a file because the resulting dumps can be big
dumpbin /exports fileToDump.lib > dumpResult.txt
Bonus tip: sometimes in one dump you will see unsigned short and
in another wchar_t
This means the compilation was not done with the same settings
for wchar_t (native type or not)