lnk1136 - invalid or corrupt .lib

921 Views Asked by At

I've got a little problem. I got a dll C library, a header file, and all other files needed to call this dll. I've tried calling this dll through third party programs and it is working. However, when I try calling it directly (dynamic linking at load and using the given header file) I always get the linker error 1136 with mydll.lib.

Using the header file:

#include "windows.h"
#include "mydll.h"

void main() {
    bool test;
    test = CallDll("MyArg");
}

With code in headerfile as below:

extern "C" bool _stdcall CallDll(char* MyArg);

Using dynamic linking at load time:

#include "windows.h"

bool(*CallDll)(char*);
HINSTANCE h = LoadLibrary((LPCSTR)"mydll");

void main() {
    CallDll = (bool(*)(char*))GetProcAddress(h, "CallDll");
    bool test;
    test = CallDll("MyArg");
}

Now what did I do wrong? I doubt the mydll.lib file is broken, because if this were the issue, I couldn't access the dll with a third party program.

1

There are 1 best solutions below

1
On BEST ANSWER

Well it was a rather simple solution.

bool(*CallDll)(char*);
HINSTANCE h = LoadLibrary(L"mydll.dll");

void main() {
    CallDll = (bool(*)(char*))GetProcAddress(h, "CallDll");
    bool test;
    test = CallDll((char*)"MyArg");
}

Was all it needed...