The CLIPS (C-language Integrated Production System) product appeared in 1984 as a medium for developing expert systems for NASA projects. Despite the fact that this project was suspended, the developers continued to improve this environment - the last update was released in 2006.
CLIPS provides integration into various applications written in both C and C ++ languages, and in Java. Interestingly, in the advanced manual of the environment programmer, the options for integration into windows-applications are shown, but there is not a word about integration into applications written for Linux.
In the process of writing my dissertation, I encountered the following problem: my expert system had to be run in a Linux-like OS, while the main application using the expert system had to be written in pure C. Fedora was chosen to test this possibility, and all the code was written in ECLIPSE. Perhaps this experience may seem useful to someone.
To begin with, CLIPS offers the following integration options [1]:
')
1. Integration using open source.
The presence of open source means that you need to recompile the entire project, “hooking” to it all the source files, and then go to all the functions of the environment directly. The option was cut off, because in addition to connecting the expert system, it was necessary to still process the data coming into it in real time, and I did not want to waste time on a constant long compilation.
2. Integration with the use of DLL.
One of the main options offered by developers, the manual has a full description of the functions and options for their connection. A great option for Windows applications, but absolutely unsuitable for use in Linux.
3. Integration using Shared objects.
Developers carefully compiled library libclips.so, available in the repository, but completely forgotten in the documentation. This option was adopted for implementation, although at some points I regretted it very much.
Using the example of the main function “create an environment”, the final actions for connecting this library to the program can be described by the following algorithm:
1. Using the command nm -D /usr/lib/libclips.so.2.0.0 you get a list of all the functions that are in the library. The underwater stone is that some of the functions of this library have names that do not match in the header files. For example, the CreateEnvironment function is written as __CreateEnvironment.
2. In header files we look for the description of a specific function and define it as a type in our program:
typedef void * (* CreateEnvironmentPtr) (void);3. Then a variable of this type is defined:
CreateEnvironmentPtr __CreateEnvironment;4. After the standard connection of the library libclips.so using the dlopen command, the function is loaded from the library:
__CreateEnvironment = (CreateEnvironmentPtr) dlsym (dll_handle, "CreateEnvironment");5. A pointer is defined:
void * theEnv;with the help of which the CLIPS environment is created:
theEnv = __CreateEnvironment ();After executing the standard for the environment actions on loading the launch of the expert system, the final program fully uses the mechanism of expert systems. For example, as shown in the picture:

Thus, we launched the environment for creating expert systems (as well as the expert system itself) in an application written for Linux.
PS The program can fully transfer control to the environment using the CommandLoop command and implementing the system command line.
Literature
1. CLIPS Reference Manual. Volume II. Advanced Programming Guide.