Clips and C++

65 views
Skip to first unread message

Diana Chen

unread,
May 11, 2020, 11:29:14 AM5/11/20
to CLIP...@googlegroups.com
Hello,

I'm starting out as a new user to clips and C++, and I'm having trouble get the two languages to mix. I tried compiling the C files as C++ after deleting the main.c

I used:
g++ *.c -o test -lm -x c++

But I got the error:
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

Can you help? Also, is there documentation of step by step compiling and using clips in c++?

Thank you!

Diana

CLIPS Support

unread,
May 11, 2020, 4:23:42 PM5/11/20
to CLIPSESG
The CLIPS source code is both valid C and C++ code so all you have to do to compile it with a C++ compiler is to specify that the C source files should be compiled as C++ files:

$ g++ -o clips -x c++ *.c -lstdc++
$ ./clips
         CLIPS (6.31 6/12/19)
CLIPS> (exit)
$

If you remove the file main.c and don't provide an alternate main routine in another file, then the linker will generate an error when trying to create the executable because there's no starting point for the program:

$ g++ -o clips -x c++ *.c -lstdc++
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Reply all
Reply to author
Forward
0 new messages