undefined reference to InitCImage_1 when building run time module

25 views
Skip to first unread message

Ryan Johnston

unread,
Apr 10, 2024, 6:41:05 PMApr 10
to CLIPSESG
Using a fresh clips core 641 source tar, I followed the steps listed in apg to create a run time module. Here is some output from what i'm trying:

$ cat main.c
#include <stdio.h>
#include "clips.h"
extern Environment *InitCImage_1(void);
main()
{
Environment *env;
env = InitCImage_1();
Reset(env);
Run(env,-1);
DestroyEnvironment(env);
}
$ grep -nr InitCImage_1 .
./examp.c:16:Environment *InitCImage_1()
./main.c:3:extern Environment *InitCImage_1(void);
./main.c:7:env = InitCImage_1();
./examp.h:479:   Environment *InitCImage_1(void);

When I try to run `make` again after setting RUN_TIME to 1 in setup.h, I get:

gcc -o clips main.o -L. -lclips -lm
/usr/bin/ld: main.o: in function `main':
main.c:(.text.startup+0x6): undefined reference to `InitCImage_1'
collect2: error: ld returned 1 exit status
make: *** [makefile:94: clips] Error 1

CLIPS Support

unread,
Apr 10, 2024, 8:00:56 PMApr 10
to CLIPSESG
If you use make to build the run time executable, you need to add the files generated by constructs-to-c to the make file. When I create run time executables for testing, I just create them using "gcc -o clips -DRUN_TIME=1 *.c"

Ryan Johnston

unread,
Apr 11, 2024, 10:24:04 AMApr 11
to CLIPSESG
Thanks, Gary, that seems to have done it. I added the following to my makefile for convenience:

run_time : clean
        rm -f run_time
        gcc -o run_time -DRUN_TIME=1 *.c -lm

CLIPS continues to impress.
Reply all
Reply to author
Forward
0 new messages