I'm trying to load a plugin I made
#define WIN32
#include "main.h"
#include "SqImports.h"
HSQAPI hSQ;
HSQUIRRELVM hVM;
PluginFuncs * hFunctions;
bool bServerRunning = false;
void OutputMessage(const char * msg)
{
#ifdef WIN32
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbBefore;
GetConsoleScreenBufferInfo(hstdout, &csbBefore);
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
printf("[MODULE] ");
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
printf("%s\n", msg);
SetConsoleTextAttribute(hstdout, csbBefore.wAttributes);
#else
printf("%c[0;32m[MODULE]%c[0;37m %s\n", 27, 27, msg);
#endif
}
void OnSquirrelScriptLoad()
{
size_t nSize;
int32_t nSqID = hFunctions->FindPlugin("SQHost2");
if (nSqID != -1)
{
void **SqExports = hFunctions->GetPluginExports(nSqID, &nSize);
if (SqExports != NULL && nSize > 0)
{
SquirrelImports ** SqDerefFunctions = (SquirrelImports **)SqExports;
SquirrelImports * SqFunctions = (SquirrelImports *)(*SqDerefFunctions);
if (SqFunctions)
{
hSQ = *(SqFunctions->GetSquirrelAPI());
hVM = *(SqFunctions->GetSquirrelVM());
}
}
else
{
OutputMessage("Failed to attach to SQHost2");
}
}
}
void OnServerShutdown()
{
OutputMessage("Closing Dixord connections");
}
uint8_t OnServerInitialize()
{
OutputMessage("Initialized Dixord by Ice Flake");
return true;
}
uint8_t OnPluginCommand(uint32_t nCommandIdentifier, const char* sMessage)
{
switch (nCommandIdentifier)
{
case 0x7D6E22D8:
OnSquirrelScriptLoad();
break;
}
return true;
}
extern "C" unsigned int VcmpPluginInit(PluginFuncs* h_Functions, PluginCallbacks* h_Callbacks, PluginInfo* h_Info)
{
h_Info->pluginVersion = 0x1000;
strncpy(h_Info->name, "Dixord", sizeof(h_Info->name));
h_Info->apiMajorVersion = PLUGIN_API_MAJOR;
h_Info->apiMinorVersion = PLUGIN_API_MINOR;
hFunctions = h_Functions;
h_Callbacks->OnServerInitialise = OnServerInitialize;
h_Callbacks->OnPluginCommand = OnPluginCommand;
h_Callbacks->OnServerShutdown = OnServerShutdown;
return 1;
}
(where main.h and SQImports.h are the same as here (https://bitbucket.org/ysc3839/0.4-cmdinput/src/b05869a03e96))
I compiled it using VS 2015 community and it gives me the following error:
Plugin error >> GetProcAddress() 'plugins/dixord04rel64.dll' failed: Code 127
Failed to load plugin: dixord04rel64
Why does this occur?
Solved by changing
extern "C" unsigned int VcmpPluginInit(PluginFuncs* h_Functions, PluginCallbacks* h_Callbacks, PluginInfo* h_Info)
to
extern "C" EXPORT unsigned int VcmpPluginInit(PluginFuncs* h_Functions, PluginCallbacks* h_Callbacks, PluginInfo* h_Info)