
This directory contains various examples that show how to call XSB
from a main C program.  (You may also call XSB from a C function that
has been called from XSB as foreign code.  You can see examples of
this way to call XSB in the directory ../XSB_calling_c.)

cvarstring.c shows how to use the VarString interface, cfixedstring.c
shows how to use the fixed string interface.   These two files can be
compiled and run under both the single- and multi-threaded engines.

cvarstring_thread.c shows how to use the VarString interface with
multiple threads.  It can be compiled and run only under the
multi-threaded engine.

cmain.c cmain2.c show how to use the register interface.  These files
were written for the single-threaded engine, and have not been updated
for the multi-threaded engine.

See the manual for details on commands used in these files.

The easiest way to create them as executables is to consult './make.P'
(for cvarstring.c and cfixedstring.c), ./make_thread.P (for
cvarstring_thread.c) or './makealt.P' (for cmain.c and cmain2.c) from
the configuration of XSB you wish to use (for instance, using the
sequential or multi-threaded engine).  Each of these make files should
automatically obtain the proper directory names, compilation flags and
load flags to compile with your architecture and configuration.

Alternately, you can adapt ./Makefile to make these files.  ./Makefile
was written for Linux, so it will probably require some tweaking to
determine the proper directory names and flags.  To obtain these
values, first check that the file

$XSB_HOME/config/<your system architecture>/modMakefile 

is present.  If not, execute "makexsb module" in the $XSB_home/build
directory.  modMakefile can then be used or adapted to statically link
your own programs with XSB.  This make file contains all the right
settings, but you will have to fill in the actual name of your program
that calls the XSB module.

Both processes execute the following two steps for a file cmain.c that
is to be made into an executable cmain.

1. cmain is compiled to create cmain.o using the proper compiler flags
2. cmain.o is linked with files in 
   $XSB_HOME/config/<your system architecture/saved.o 
   under the proper compiler flags to create cmain.

*******************************************
FURTHER NOTES:

If the executables are not created due to unresolved references, check
that the CFLAGS are correct for your system and compiler.  This can be
done by running XSB and executing:
| ?- xsb_configuration(compiler,Compiler),
	xsb_configuration(compiler_flags,CFLAGS).

and checking that the C compiler and flags are correct for the system
you are running, and fixing them if not.

