### GAP Installation (Google Translation)
These instructions should help you to install GAP on your computers. GAP works on Linux, macOS or Windows. There is a section for each of these operating systems. Follow the instructions there, including the guides we link to, and try everything **before** we meet.
In this manual you will always find commands with a gray background, such as the following:
```
#I am a command
```
You should execute these commands in a terminal of your choice. Linux users should already be familiar with this, but you can also open the "Terminal" app on macOS and enter the commands there. On Windows, please first follow the instructions to enable WSL as described below, then type the commands in the window that opens when you start Ubuntu. As a tip: You can also copy the commands directly into the terminal window and then run them with Enter. Then you don't have to type as much.
Please understand that we can only help you with the current versions of the operating systems. Unfortunately, we cannot help you, especially on older Windows versions.
## Preparations on Windows
GAP is best used on Linux. Fortunately, Windows 10 with the so-called Windows Subsystem for Linux (WSL for short) offers the possibility to easily install Linux via the Microsoft Store.
For this you need on the one hand a current Windows 10 and on the other hand the possibility to run programs as an administrator.
A very detailed guide to WSL can be found [here](https://adamtheautomator.com/windows-subsystem-for-linux/). Please activate WSL as described there and install Ubuntu in the store. Then start Ubuntu to allow the installation to complete and create a user (you will be asked for a username and password, just provide it).
You can now start Ubuntu in Windows as an app as normal. It then looks like this:

You are all set and now have Linux on Windows. The Linux distro you installed is not yet set up at this point. So continue with Linux preparation below before you install GAP!
## Preparation on macOS
In macOS, we first need a C compiler. On all recent versions of macOS, you can install the required tools by entering the following command into a terminal prompt (note that it will show a graphical prompt asking for confirmation, and may also require you to enter an administrator password).
```
xcode-select --install
```
We also need the Homebrew package manager (MacPorts also works if you already have it). It's quick to install, just open the terminal and follow the instructions [here](https://brew.sh/).
Now we can use the package manager to download the tools we need to compile GAP. To do this, we enter the following command in the terminal:
```
brew install autoconf libtool gmp readline wget unzip
```
Now everything is prepared. The rest of the instructions can be found below at **Compile GAP**.
## Preparation on Linux
We will compile GAP ourselves. For this we need some packages. This guide assumes you are using Ubuntu. For other distributions adjust the calls to the package manager accordingly.
First, update everything (you will be asked for your password):
```
sudo apt update
```
and then
```
sudo apt upgrade
```
Now we are ready to install all needed packages. Do the following:
```
sudo apt install build-essential autoconf libtool libgmp-dev libreadline-dev zlib1g-dev libncurses5-dev libncursesw5-dev gawk wget unzip
```
If some packages are already installed, that is of course not a problem. Now we're ready to compile GAP in the next section.
## Compile GAP
First we download GAP. To do this, first navigate in the terminal to the folder in which you want to install GAP. You can run the following command to do this:
```
wget https://github.com/gap-system/gap/releases/download/v4.12.0/gap-4.12.0.zip
```
It then looks something like this:

Then we have to unpack the ZIP archive.
```
unzip gap-4.12.0.zip
```
Now there is a folder named "gap-4.12.0". We now switch to these:
```
cd gap-4.12.0
```
Now let's run a series of commands one by one that will compile GAP:
```
./autogen.sh
./configure
make -j4
cd pkg
../bin/BuildPackages.sh --parallel
```
Now everything is compiled. With
```
cd ..
./gap
```
you can start your first GAP session.
Note that `.` refers to the current directory. So you always have to navigate to the `gap-4.12.0` folder first to run GAP. If this command doesn't work, you can also use `./bin/gap.sh`.
If you want, you can test your GAP installation. How to do this is described [here](https://github.com/gap-system/gap/blob/v4.11.1/INSTALL.md#6-testing-the-installation). Note that if you use Ubuntu via WSL on Windows, the instructions for Linux/macOS also apply to you.
## Make GAP startable from anywhere
As of now, you have to navigate to the `gap-4.12.0` folder in the terminal every time you want to start GAP (via `cd` or via path). You have also used other commands during the installation. If you enter `cd` or `unzip`, the corresponding program will also be started without navigating to the folder in which the program is located. This is because when you enter a command, the terminal (or the shell, but we don't care about such details for the time being) searches for a suitable program in certain folders and then runs it. You can check which folders these are by going to
```
echo $PATH
```
executes `echo` outputs the content of the so-called environment variable `PATH`.
It can look like this, for example:
```
/usr/local/bin:/usr/bin:/bin:/usr/sbin
```
The paths (i.e. folders) in which the terminal searches for the programs are separated by `:`. The terminal searches in the order in which it is in the variable. In order to be able to run GAP without navigating around, we can store GAP in one of these folders.
So that we don't have to move the entire GAP folder, we will only link GAP (or the file that is actually executed). To do this, we create a so-called symlink. First navigate to the `gap-4.12.0` folder as usual and then run the following command.
```
ln -s "path to gap"/gap /usr/local/bin/gap
```
"Path to GAP" is to be replaced by the path to the GAP installation folder. So on MacOS typically `/Users/Hans/gap-4.12.0`, where Hans should be replaced by your username.
You can check whether this was successful by entering the following:
```
ls /usr/local/bin | grep cap
```
The result should be `gap`.
Now you can launch any GAP you like using just `gap` without having to navigate to specific folders.
It is best to start GAP from the folder that contains the `.g` files that you want to run.
## Install Notepad
Since we will be writing small GAP programs, it is recommended to use an editor that supports GAP syntax. There is a lot to choose from and some editors that support GAP or for which extensions are available are listed [here](https://www.gap-system.org/Faq/faq.html#8.3). A modern, powerful editor that is recommended is Visual Studio Code. You can install it [here](https://code.visualstudio.com) and then install an extension for GAP. How to do this is described [here](https://code.visualstudio.com/docs/editor/extension-marketplace). If you search for "GAP" in the Extensions tab in Visual Studio Code, two extensions should appear. Better install the newer one (which is currently the one with the lower download numbers) because it can handle more GAP commands. But we're also happy to help you if something doesn't work.
### Working with Visual Studio Code on Windows
If you are using Windows and installed GAP on Ubuntu via WSL as described above, you can only use GAP in the Ubuntu terminal. If you write your programs and want to read them in using ``Read()`` you need to be able to access files on Windows from Ubuntu. Luckily, that's pretty easy. You can use the editor of your choice as usual under Windows and save the files wherever you normally do, for example in the folder ``Documents\Studium\Semester_3\Cobra\GAP``. On Ubuntu you will find your entire Windows file system in ``/mnt``. So you can go to the folder in Ubuntu