How to compile a GAP program in Linux/Debian?

I installed GAP in my Ubuntu 20.04.

I can write programs and compile them using terminal by writing gap then do the things that I found in GAP manual in your website without any difficult.

But, if I closed the terminal I lose everything, so obviously I have to write a program in a text editor first, then save it (this is my first problem do I have to save it as a .g file or .gap file or....?), next is to compile this program using terminal, I remember when I used C program we had to put something like this: gcc program.c -o program .

So my second question (that I am sure you guessed) is how to compile this GAP file if we use GNU compiler? Thanks in advance.


good question!

In section 2.2 of the GAP tutorial it explains that you should first save your file that contains your code with the extension .g, and then, after starting GAP in a terminal, you can use the Read() function to read your code from the file. This way, any functions or variables that you have in your file are read into GAP, to then be accessed by you later in the session.

For example, if I have some file example.g, and it is saved to my home directory, then I could navigate to my home directory in a terminal, start GAP with the gap command, and then type the following:

gap> Read("example.g");

and my code would be executed. See GAP tutorial for more info about this, in section 2.2. I am not sure if the GNU compiler would work with the GAP programming language. Hopefully this helps!


Another option using workspaces:

  • gap> SaveWorkspace("savefile"); to save workspace from inside GAP shell into a fil.

  • gap -L savefile to load the save workspace from file.