# E4068

Main function is already defined.

In MoonBit, a `main` package contains a single `main` function that serves as
the entry point of the program. Therefore, you cannot define more than one
`main` function in the main package. If you want to have multiple programs to be
built as separate binaries, you can use multiple `main` packages within the same
module.

## Erroneous example

Suppose in package `main`:

`main/moon.pkg`:

```{literalinclude} /sources/error_codes/4068_error/moon.pkg
:language: moonbit
```

`main/main.mbt`:

```{literalinclude} /sources/error_codes/4068_error/top.mbt
:language: moonbit
```

## Suggestion

You can either remove the extra `main` function:

```{literalinclude} /sources/error_codes/4068_fixed/top.mbt
:language: moonbit
```

Or you can move the extra `main` function to a different package, say `main2`:

`main2/moon.pkg`:

```{literalinclude} /sources/error_codes/4068_fixed/main2/moon.pkg
:language: moonbit
```

`main2/main.mbt`:

```{literalinclude} /sources/error_codes/4068_fixed/main2/top.mbt
:language: moonbit
```

while keeping `main/main.mbt` with only one main function:

```{literalinclude} /sources/error_codes/4068_fixed/top.mbt
:language: moonbit
```
