2

The programming language GAP has a way of compiling into C code using the compiler GAC.

I am trying to test this in the following way, to create a C program from functions written in GAP:

first.g

PrintEO := function() Print("Hello World"); end;

firstGapProg.c

#include <stdio.h>

int main()
{
    PrintEO();
    return 0;
}

I then run in Bash

$ gac -c first.g
$ ar -cvq libfirstgap.a first.o
$ cc -o gapFirstTest firstGapProg.c libfirstgap.a

This compiles the .g file to a .o, creates library then attempts to link the library and make executable. When I do this I get the error gapProg.c:(.text+0xa): undefined reference to ``G_PrintEO'.

I am guessing this is because I have no template for the function in firstGapProg.c. However I do not actually know how to call the function itself or what it has been saved as in the library?!

When I $nm libfirstgap.a I get the output:

test.o:
                 U AssGVar
                 U ChangedBags
                 U CurrLVars
                 U CurrStat
0000000000000000 b DefaultName
0000000000000070 b GF_Print
0000000000000078 b G_Print
0000000000000068 b G_PrintEO
                 U GVarName
0000000000000070 t HdlrFunc1
0000000000000340 t HdlrFunc2
                 U InitFopyGVar
                 U InitGlobalBag
                 U InitHandlerFunc
0000000000000480 t InitKernel
0000000000000200 t InitLibrary
00000000000004f0 T Init__test
0000000000000000 d module
0000000000000050 b NameFunc
0000000000000030 b NamsFunc
0000000000000010 b NargFunc
                 U NewBag
                 U NewFunction
                 U NEW_STRING
0000000000000000 t PostRestore
                 U PtrBody
                 U PtrLVars
                 U UpdateCopyFopyInfo
                 U YoungBags

Any ideas?

rwolst
  • 12,904
  • 16
  • 54
  • 75

0 Answers0