[GAP Forum] Embedding GAP functions in C code

Stephen Linton steve.linton at st-andrews.ac.uk
Sat Feb 22 16:26:19 GMT 2014


Dear Robert,

On Fri, Feb 14, 2014 at 07:37:12PM +0000, Wolstenholme, Robert wrote:
> I want to compile some of my GAP functions into static libraries for use in a C program. I have compiled them using gac -c on Ubuntu but I 'm not sure how to now call these functions in my C program. I tried a few things but whenever I tried to link and create a binary I got an error.

There is no “official” way to do this. The gac compiler converts GAP into C code which can be loaded as an extension to the
GAP kernel, but it still needs the rest of the kernel and very possibly large parts of the library in order to run. See 

http://www.gap-system.org/Faq/faq.html#8.1

Relatively recently, some of the SAGE developers have produced libGAP, which allows the entire GAP system to be embedded as a C library. You still can’t embed individual functions by themselves though and the first call to libGAP still has invoke the full GAP start-up sequence.

Alternatively, there are a number of ways of running GAP as a server process and calling it from C or C++ programs. SCSCP is probably the simplest of these to use.  Seehttp://www.gap-system.org/Packages/scscp.html for the GAP side. There are various C and C++ libraries that implement the client side.

	Yours

		Steve Linton


More information about the Forum mailing list