I'm building a C++ library (windows, DLL) and I'd like to embed swi-prolog for some functionalities.
What I'm doing is:
#include <Windows.h>
#include <SWI-Prolog.h>
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // DLL モジュールのハンドル
DWORD fdwReason, // 関数を呼び出す理由
LPVOID lpvReserved // 予約済み
)
{
BOOL result = TRUE;
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
{
char* av[]{"libswipl.dll"};
_putenv(R"(SWI_HOME_DIR=C:\Program Files (x86)\swipl\)");
if(!PL_initialise(1, av))
{
result = TRUE;
}
else
{
PL_halt(1);
result = FALSE;
}
break;
}
case DLL_PROCESS_DETACH:
{
result = PL_cleanup(1);
break;
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
}
return result;
}
and including "libswipl.lib", renamed from "swipl\lib\libswipl.dll.a".
First it gives errors because of missing dll, so I copied those in my executable folder until it was happy (specifically, libswipl.dll;libgmp-10.dll;pthreadGC2.dll).
I don't need to include a pl file into the executable (is this what swipl-ld does?) because I would like to add facts and rules dinamically by code later, so it's ok to initialize with a clear state.
What I'd like to know is, how do I get rid of the dependencies (SWI_HOME_DIR) and make it stand-alone?