I have an exe written in C to call a dll. It compiles with Clang and I'm linking it from the Visual Studio command line using link.exe. Link.exe gives me these errors:
error LNK2019: unresolved external symbol __imp_LoadLibraryA referenced in function WinMain
error LNK2019: unresolved external symbol __imp_GetProcAddress referenced in function WinMain
error LNK2019: unresolved external symbol __imp_FreeLibrary referenced in function WinMain
error LNK2019: unresolved external symbol __stdio_common_vsprintf referenced in function _vsnprintf_l
unresolved external symbol WinMainCRTStartup
These LNK2019 errors all relate to Windows API functions that are in Windows.h, and windows.h is in my header file.
This is the header file (SxSv.h):
Code:
#ifndef DLLHANDLER_C_
#define DLLHANDLER_C_
#include <windows.h>
#include <winbase.h>
#include <windef.h>
#include <stdio.h>
typedef int (*TestFunc)(int);
int loadDLL( void );
#endif
Code:
This is the C file (SxSv.c) :
#include "SxSv.h"
int WinMain()
{
int status = 0;
TestFunc _TestFunc;
HINSTANCE testLibrary = LoadLibrary("SxSv.dll");
if (testLibrary) {
_TestFunc = (TestFunc) GetProcAddress(testLibrary, "SSXV");
if (_TestFunc) {
status = _TestFunc();
}
FreeLibrary(testLibrary);
}
return status;
}
The link string for Link.exe:
link SxSv SxSv.obj
I have an include for Windows.h specified in the header file, so what else do I need to reference?
Thanks.