Getting started with C integration

44 views
Skip to first unread message

Ruisch

unread,
Jul 30, 2025, 1:14:52 AMJul 30
to CLIPSESG
Hello, I'm an amateur, learning CLIPS to create expert systems with the available documentation and examples. These have been excellent for getting started using the CLIPS language itself, but I'm increasingly needing its C-language integration.

What are the resources available for getting started in learning the "CLI" of CLIPS? Volume II of the Reference Manuals is useful, but is there anything more beginner-friendly such as a step-by-step tutorial?

ChatGPT-4o is how I discovered CLIPS in the first place, and it has been helpful in learning and problem-solving my programs, but it's not helpful with C-language integration. It's suggesting that the source code files I'm using are incomplete. I am using clips_core_source_642 from https://sourceforge.net/projects/clipsrules/files/CLIPS/6.4.2/ which is linked to from https://www.clipsrules.net/ .  Just to confirm, are these files all I need for C-language integration of CLIPS?

Ryan Johnston

unread,
Jul 30, 2025, 10:48:31 AMJul 30
to clip...@googlegroups.com

Hey, Ruisch,

Welcome to CLIPS! You'll want to check out the Advanced Programming Guide: https://www.clipsrules.net/documentation/v642/apg642.pdf


--
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To post to this group, send email to CLIP...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en
 
--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Click on "Edit my membership" link.
Select the "No Email" radio button.
Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Sign in
Click on "Edit my membership" link.
Click the "Unsubscribe" button.
Note: This appears to be the most reliable way to unsubscribe
 
Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.
---
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/clipsesg/26110b93-e38f-4391-ae88-a275f9d410cfn%40googlegroups.com.

Basile Starynkevitch

unread,
Jul 30, 2025, 11:10:36 AMJul 30
to clip...@googlegroups.com
On Tue, 2025-07-29 at 20:04 -0700, Ruisch wrote:
> Hello, I'm an amateur, learning CLIPS to create expert systems with the
> available documentation and examples. These have been excellent for getting
> started using the CLIPS language itself, but I'm increasingly needing its C-
> language integration.

What is the topic of the expert system you are creating? Is it open source? Then
where is the repository?

>
> What are the resources available for getting started in learning the "CLI" of
> CLIPS? Volume II of the Reference Manuals is useful, but is there anything
> more beginner-friendly such as a step-by-step tutorial?
>
> ChatGPT-4o is how I discovered CLIPS in the first place, and it has been
> helpful in learning and problem-solving my programs, but it's not helpful with
> C-language integration. It's suggesting that the source code files I'm using
> are incomplete. I am using clips_core_source_642 from
> https://sourceforge.net/projects/clipsrules/files/CLIPS/6.4.2/ which is linked
> to from https://www.clipsrules.net/ .  Just to confirm, are these files all I
> need for C-language integration of CLIPS?
> --


You obviously need a C compiler, and I hope you are using CLIPS on a Linux
system. Then https://gcc.gnu.org/ is a good C compiler.

You could need a debugger: Gnu GDB.

Of course you need a builder program: GNU make.

Linux and Posix systems can accept many plugins (actually many dozen of
thousands in practice) using https://man7.org/linux/man-pages/man3/dlopen.3.html
and https://man7.org/linux/man-pages/man3/dlsym.3.html


You might consider generating some of the C glue code. This could be done with
another CLIPS expert system, (or with a packet of rules) taking ideas from
https://arxiv.org/abs/1109.0779


On my side, I am (with a few others) developing a new expert system engine,
capable of taking advantage of multi-core processors and multi-threading.

It is RefPerSys on github. Coded in C++, GPL licensed, and work in progress (so
not mature like clipsrules.net is in 2025). See also refpersys.org for some
design ideas (or ask me for a paper summarizing them).

I tend to believe that a better than CLIPS syntax is welcome.

(I do know about https://www.why3.org/ ...)

Regards from near Paris in France
--
Basile STARYNKEVITCH <bas...@starynkevitch.net>
8 rue de la Faïencerie http://starynkevitch.net/Basile/
92340 Bourg-la-Reine https://github.com/bstarynk
France https://github.com/RefPerSys/RefPerSys

CLIPS Support

unread,
Jul 30, 2025, 3:56:33 PMJul 30
to CLIPSESG
What are some of the things that you would want a step-by-step tutorial to teach you?

Ruisch

unread,
Jul 31, 2025, 3:35:53 AMJul 31
to CLIPSESG
My aim is simply to learn whatever I need to learn get started, so the first steps would be a CLIPS function that calls a C function to print "hello world", and vice versa from CLIPS in C. Since I asked my question here, I have managed to prompt ChatGPT to give me a working C function that passes the system time from C to CLIPS. Compiling and running it was a breakthrough for me, so now I'm seeking to understand how it works, and then figure out what I need to learn next.  I don't know what I need to know, so it's difficult to be more specific.

By the way, many thanks for your work Gary, and for making it accessible.

Ruisch

unread,
Jul 31, 2025, 3:58:25 AMJul 31
to CLIPSESG
Hey Ryan,

Thanks, it's great to find this group. The Advanced Programming Guide is what I was referring to when I mentioned 'Volume II of the Reference Manuals'. I don't yet have the required background understanding to make full use of it, but I'm willing and able to learn, if I know which topics and skills to focus on.

Ruisch

unread,
Jul 31, 2025, 4:28:33 AMJul 31
to CLIPSESG
Hi Basile,

Thanks for your reply. Yes, I am using Linux (Debian 12). The program I'm making is just a learning project, based on simple examples. I have taken the RPG example from 'Adventures in Rule-Based Programming' and adapted it to personal habit management decisions and situation-specific reminders in my own everyday life. Other than the benefits of personal customisations of the originial examples, I don't think I've made any improvements of value to anyone else. If or when I do I'll be happy to share open source.

Thanks also for your other suggestions. I'm already using some of the tools you recommended, and others are too advanced for me although interesting, but I am following your suggestion of the GNU debugger.

Ryan Johnston

unread,
Jul 31, 2025, 12:00:13 PMJul 31
to clip...@googlegroups.com
When I was first learning CLIPS, I dove deep into the Beginners Programming Manual, learning how the language works, and tried to create various projects using the language. This gave me a really good idea of what the language could do without any modifications to it. The C interface came in handy when I ran up against some functionality not present in the core language.

Here's a few links to step-by-step style articles I created that branched out to use the CLIPS C Interface:


Here's a few links to source code I created that use the CLIPS C Interface (not step-by-step guides):


--
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To post to this group, send email to CLIP...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en
 
--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Click on "Edit my membership" link.
Select the "No Email" radio button.
Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Sign in
Click on "Edit my membership" link.
Click the "Unsubscribe" button.
Note: This appears to be the most reliable way to unsubscribe
 
Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.
---
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+u...@googlegroups.com.

CLIPS Support

unread,
Jul 31, 2025, 9:52:40 PMJul 31
to CLIPSESG
The Advanced Programming Guide organizes the topics by my assessment of what's most likely to be useful as well as placing simpler topics first. Most of the chapters have examples at the end, which is why I asked what you trying to do. It's nice to have full coverage without redundancy. 

Here's some code for a hello world function you can add to userfunctions.c. It shows how you can call out from CLIPS to a C function and then have that C function call back into CLIPS.

void HelloCommand(Environment *,UDFContext *,UDFValue *);
 
void HelloCommand(
  Environment *theEnv,
  UDFContext *context,
  UDFValue *returnValue)
  {
   Writeln(theEnv,"Hello World");
   Eval(theEnv,"(println Goodbye)",NULL);
  }
 
void UserFunctions(
  Environment *env)
  {
   AddUDF(env,"hello","v",0,0,"",HelloCommand,"HelloCommand",NULL);
  }


Calling the function from CLIPS will produce this output:

CLIPS> (hello)
Hello World
Goodbye
CLIPS> 


Ruisch

unread,
Aug 1, 2025, 7:44:09 AMAug 1
to CLIPSESG
Thanks Ryan, the articles are useful and give a better idea of some of the possibilities, although there are still gaps in my understanding to fill before I'm capable of implementing in my own projects. I'm also wondering whether to just use Python with CLIPSPy. I'd prefer C, but it's hard to justify the extra pain.

Ruisch

unread,
Aug 1, 2025, 8:12:39 AMAug 1
to CLIPSESG
Thank you very much for the example. I've complied and ran it successfully, so it's a useful and instructive starting point to build on. My impression of the Advanced Programming Guide was that its for reference like a dictionary. Thanks for informing me that it's organised in order of difficulty. Studying and using the examples in order seems the best available way to learn.
Reply all
Reply to author
Forward
0 new messages