Use DLL in C without lib

Yes you can. You should use the GetProcAddress function, to call the function directly in the DLL, without involving the LIB

Processes explicitly linking to a DLL call GetProcAddress to obtain the address of an exported function in the DLL. You use the returned function pointer to call the DLL function.

To quote the Example from the above link:

typedef UINT (CALLBACK* LPFNDLLFUNC1)(DWORD,UINT);
...

HINSTANCE hDLL;               // Handle to DLL
LPFNDLLFUNC1 lpfnDllFunc1;    // Function pointer
DWORD dwParam1;
UINT  uParam2, uReturnVal;

hDLL = LoadLibrary("MyDLL");
if (hDLL != NULL)
{
   lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,
                                           "DLLFunc1");
   if (!lpfnDllFunc1)
   {
      // handle the error
      FreeLibrary(hDLL);
      return SOME_ERROR_CODE;
   }
   else
   {
      // call the function
      uReturnVal = lpfnDllFunc1(dwParam1, uParam2);
   }
}

You can use LoadLibrary() and GetProcAddress() as described in the answer by DarkXphenomenon. Or, another alternative is to create your own import library for the DLL by creating a .def file then running that through the LIB command to generate an import library. Additional details here:

http://support.microsoft.com/kb/131313

Tags:

C

Dll