# Are there any Swi-Prolog COM or ActiveX components?

**URL:** <https://swi-prolog.discourse.group/t/are-there-any-swi-prolog-com-or-activex-components/4208>\
**Category:** Tools\
**Created:** [July 27, 2021, 11:21pm UTC](https://swi-prolog.discourse.group/t/are-there-any-swi-prolog-com-or-activex-components/4208 "2021-07-27T23:21:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SWIExplorer](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/swiexplorer/32/2868_2.png) [@SWIExplorer](https://swi-prolog.discourse.group/u/SWIExplorer)\
**Post date:** [July 27, 2021, 11:21pm UTC](https://swi-prolog.discourse.group/t/are-there-any-swi-prolog-com-or-activex-components/4208/1 "2021-07-27T23:21:35Z")

</div>

Hi,

Is there a component I can use in VBScript or JScript, in a Windows Scripting Host environment? Or just a DLL, with some Usage samples?

There apparently used to be something here

[http://logicmoo.sourceforge.net/SwiActX/](http://logicmoo.sourceforge.net/SwiActX/)

referenced at

[http://logicmoo.sourceforge.net/](http://logicmoo.sourceforge.net/)

, but the link isn’t active.

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [July 28, 2021, 12:33pm UTC](https://swi-prolog.discourse.group/t/are-there-any-swi-prolog-com-or-activex-components/4208/2 "2021-07-28T12:33:08Z")

</div>

If you install SWI-prolog for windows, you actually have a dll, and you will also find some documentation on how to use it on the webpage. I am currently developing an R \<-\> swipl interface that connects to the dll. For an example implementation, have a look at [GitHub - mgondan/rolog: Access SWI-Prolog from R](https://github.com/mgondan/rolog), especially the file [rolog/rolog.cpp at ef21e9b51dd8471f847c5f58578639d8431c0c7d · mgondan/rolog · GitHub](https://github.com/mgondan/rolog/blob/ef21e9b51dd8471f847c5f58578639d8431c0c7d/src/rolog.cpp). Under Windows, the biggest challenge is to get PATH and a bunch of other environment variables right, see the lengthy installation instructions for rolog.

---

<div class="post-metadata">

**Author:** ![SWIExplorer](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/swiexplorer/32/2868_2.png) [@SWIExplorer](https://swi-prolog.discourse.group/u/SWIExplorer)\
**Post date:** [July 28, 2021, 5:25pm UTC](https://swi-prolog.discourse.group/t/are-there-any-swi-prolog-com-or-activex-components/4208/3 "2021-07-28T17:25:33Z")

</div>

Thanks Mgondan1,

I did install it the other day, and looked up all the DLLs. None of them are obviously the one we would use for external access.

```nohighlight
 7/28/2021 13:23 <DIR> .
 7/28/2021 13:23 <DIR> ..
 1/27/2021 3:51 35,328 archive4pl.dll
 1/27/2021 3:51 35,840 bdb4pl.dll
 1/27/2021 3:51 25,088 cgi.dll
 1/27/2021 3:51 30,720 crypt.dll
 1/27/2021 3:51 45,056 crypto4pl.dll
 7/28/2021 13:23 0 dlls.txt
 1/27/2021 3:51 30,720 double_metaphone.dll
 1/27/2021 3:51 24,064 files.dll
 1/27/2021 3:51 40,960 hashstream.dll
 1/27/2021 3:51 34,816 http_stream.dll
 1/27/2021 3:51 35,328 inclpr.dll
 1/27/2021 3:51 18,432 isub.dll
 1/27/2021 3:51 65,536 jpl.dll
 1/27/2021 3:51 18,944 json.dll
 7/01/2020 5:22 1,150,611 libarchive-13.dll
 7/25/2019 22:44 2,422,326 libcrypto-1_1-x64.dll
 7/01/2020 5:25 2,041,497 libdb-6.1.dll
 8/27/2019 13:53 1,067,151 libgcc_s_seh-1.dll
 7/25/2019 22:17 473,601 libgmp-10.dll
 7/25/2019 22:24 650,036 libjpeg-62.dll
 7/25/2019 22:31 285,514 libpcre-1.dll
 7/25/2019 22:44 435,286 libssl-1_1-x64.dll
 1/27/2021 3:51 1,496,064 libswipl.dll
 7/25/2019 22:45 67,931 libwinpthread-1.dll
 7/01/2020 5:20 592,715 libyaml-0-2.dll
 1/27/2021 3:51 20,480 md54pl.dll
 1/27/2021 3:51 33,280 memfile.dll
 1/27/2021 3:51 26,112 ntriples.dll
 1/27/2021 3:51 63,488 odbc4pl.dll
 1/27/2021 3:51 29,184 pcre4pl.dll
 1/27/2021 3:51 19,456 pdt_console.dll
 1/27/2021 3:51 2,060,800 pl2xpce.dll
 1/27/2021 3:51 25,088 plregtry.dll
 1/27/2021 3:51 61,440 plterm.dll
 1/27/2021 3:51 26,624 porter_stem.dll
 1/27/2021 3:51 34,304 process.dll
 1/27/2021 3:51 18,944 prolog_stream.dll
 1/27/2021 3:51 18,432 protobufs.dll
 1/27/2021 3:51 200,704 rdf_db.dll
 1/27/2021 3:51 17,408 readutil.dll
 1/27/2021 3:51 193,536 sgml2pl.dll
 1/27/2021 3:51 43,008 sha4pl.dll
 1/27/2021 3:51 150,016 snowball.dll
 1/27/2021 3:51 41,984 socket.dll
 1/27/2021 3:51 70,656 ssl4pl.dll
 1/27/2021 3:51 20,480 streaminfo.dll
 1/27/2021 3:51 60,928 table.dll
 1/27/2021 3:51 44,032 tex.dll
 1/27/2021 3:51 30,720 time.dll
 1/27/2021 3:51 59,392 turtle.dll
 1/27/2021 3:51 547,328 unicode4pl.dll
 1/27/2021 3:51 31,232 uri.dll
 1/27/2021 3:51 52,224 uuid.dll
 1/27/2021 3:51 25,088 websocket.dll
 1/27/2021 3:51 31,744 yaml4pl.dll
 8/05/2019 19:23 95,536 zlib1.dll
 1/27/2021 3:51 22,528 zlib4pl.dll
          15,299,740 bytes in 57 files and 2 dirs 15,400,960 bytes allocated
      69,986,783,232 bytes free

```

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [July 28, 2021, 6:03pm UTC](https://swi-prolog.discourse.group/t/are-there-any-swi-prolog-com-or-activex-components/4208/4 "2021-07-28T18:03:21Z")

</div>

libswipl.dll is the dll you’re looking for.

A very simple hello world in c++ („member.cpp“)

```cpp
#include "SWI-cpp.h"
#include <iostream>
int main(int argc, char** argv)
{
PlEngine e(argc, argv) ;
PlTermv args(2) ; // Prepare for member/2
args[0] = PlTerm(1.0) ; // first argument to member below
// args[1] is a variable
PlQuery q("member", args) ; // member(1, X)
q.next_solution() ; // now args[1] has [1 | _]
std::cout << (char*) args[1] << std::endl ;
q.next_solution() ; // now args[1] has [_, 1 | _]
std::cout << (char*) args[1] << std::endl ;
}

```

Compile with `swipl-ld -o member member.cpp`

As far as I understand, `swipl-ld` adds a few compiler switches,  
` -fPIC -D_REENTRANT -D __SWI_PROLOG__ -D __SWI_EMBEDDED__ -mtune=generic`,  
as well as a few linker flags,  
`-lswipl -Wl,-Bsymbolic-functions`.  
All this applies for `gcc`, unsure how it is in other systems.

Note that you can build SWI-Prolog yourself under `MSYS2/gcc`, see here:

[https://swi-prolog.discourse.group/t/compiling-with-msys2/3936/8](https://swi-prolog.discourse.group/t/compiling-with-msys2/3936/8)

See also the manual:

[https://www.swi-prolog.org/pldoc/man?section=cpp-embedding](https://www.swi-prolog.org/pldoc/man?section=cpp-embedding)  
[https://www.swi-prolog.org/pldoc/man?section=plld](https://www.swi-prolog.org/pldoc/man?section=plld)

---

<div class="post-metadata">

**Author:** ![SWIExplorer](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/swiexplorer/32/2868_2.png) [@SWIExplorer](https://swi-prolog.discourse.group/u/SWIExplorer)\
**Post date:** [July 28, 2021, 6:25pm UTC](https://swi-prolog.discourse.group/t/are-there-any-swi-prolog-com-or-activex-components/4208/5 "2021-07-28T18:25:12Z")

</div>

“libswipl.dll is the dll you’re looking for.”

That’s what I need, thanks. From that and the docs, I should be able to figure out how to call it with JScript or VBScript via CreateObject()

Thanks and Regards,
