# 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:** 1\
**Showing post:** 4

<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)

---

_[View the full topic](https://swi-prolog.discourse.group/t/are-there-any-swi-prolog-com-or-activex-components/4208)._
