Embedding SWI-Prolog in a dll

半城伤御伤魂 提交于 2019-12-04 17:11:05

I have never used SWI-Prolog, but looking at the installed files, some of the files installed there seem to be required to run the prolog engine.

If you mean you want to embed everything into your dll, it would probably not be possible, the only way would be modifying swi-prolog itself. But that won't be easy.

If you just don't want to require swi-prolog to be installed to have your program running. you can create your own installer which included all files to run swi-prolog, and include it in your own (sub)directory. You still need to set SWI_HOME_DIR, but you will know the relative directory to your executable.

If you don't want to use _putenv to set SWI_HOME_DIR, you can also set SWI_HOME_DIR in the windows system settings to the correct value.

Oleh Sky

First I would not recommend to initialize prolog in the DllMain, pls see here:

But, you could still use it and check if dependent libraries are there, not only libswipl.dll which changed to swipl.dll from the version 5.10, but also:

  • pthreadVC2.dll for 64 bits or pthreadVC.dll for 32 bits
  • plterm.dll (optional, terminal emulation)

Then, I would add and export a function to initialize prolog, and set required parameters (like: saved-state filename or boot32.prc/boot64.prc, flags e tc).

And, you dont need SWI_HOME_DIR when you pass all required parameters to your PL_initialise function.

Also, in case of MultiThreaded environment, these calls are required: PL_thread_attach_engine and PL_thread_destroy_engine.

More on the topic is here: swi-prolog

Cheers!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!