Are there any Swi-Prolog COM or ActiveX components?

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/

referenced at

http://logicmoo.sourceforge.net/

, but the link isn’t active.

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, especially the file rolog/rolog.cpp at ef21e9b51dd8471f847c5f58578639d8431c0c7d · mgondan/rolog · GitHub. Under Windows, the biggest challenge is to get PATH and a bunch of other environment variables right, see the lengthy installation instructions for rolog.

1 Like

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.

 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

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

A very simple hello world in c++ („member.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

See also the manual:

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

2 Likes

“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,