# How to make an executable

**URL:** <https://forum.modular.com/t/how-to-make-an-executable/698>\
**Category:** Mojo\
**Created:** [March 10, 2025, 5:04am UTC](https://forum.modular.com/t/how-to-make-an-executable/698 "2025-03-10T05:04:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AffableHoneyBadger](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@AffableHoneyBadger](https://forum.modular.com/u/AffableHoneyBadger)\
**Post date:** [March 10, 2025, 5:04am UTC](https://forum.modular.com/t/how-to-make-an-executable/698/1 "2025-03-10T05:04:59Z")

</div>

Sorry for this super basic question.

I’m coming to Mojo from a primarily Python background. My only real exposure to a compiled language is Rust (of which I’m very beginner). In Rust, I use Cargo to `init`, `add`, `run`, `build`, Rust code. So I thought with Mojo, Magic filled this role? However, this evening while playing/testing, I found there is no `magic build` command. I then tried to do `mojo build` and got prompted that command “mojo” not found.

I’m running Mojo in WSL (Ubuntu) on Win 11 and using VS Code. When I use the “play” button in VS Code, things run just fine, but I don’t think it’s building an executable.

How do you turn a .mojo file into an executable?

---

<div class="post-metadata">

**Author:** ![lesoup-mxd](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/lesoup-mxd/32/585_2.png) [@lesoup-mxd](https://forum.modular.com/u/lesoup-mxd)\
**Post date:** [March 10, 2025, 8:06am UTC](https://forum.modular.com/t/how-to-make-an-executable/698/2 "2025-03-10T08:06:42Z")

</div>

Initialise a “magic shell” first. Then you can run mojo build)

---

<div class="post-metadata">

**Author:** ![AffableHoneyBadger](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@AffableHoneyBadger](https://forum.modular.com/u/AffableHoneyBadger)\
**Post date:** [March 10, 2025, 4:13pm UTC](https://forum.modular.com/t/how-to-make-an-executable/698/3 "2025-03-10T16:13:54Z")

</div>

@lesoup-mxd Thank you! That worked!

I had a few follow-up errors that I was able to solve. I’m going to share them here, in case someone searches.

After entering the shell `magic shell` I ran the following:

```sh
mojo build main.mojo

```

But got the following error:

```sh
mojo: error: unable to find suitable c++ compiler for linking

```

This is because I was missing the `build-essentials` on Ubuntu. Which I installed:

```sh
sudo apt-get install build-essential

```

I tried to do `mojo build main.mojo` again and got the following errors:

```sh
/usr/bin/ld: cannot find -lz: No such file or directory
/usr/bin/ld: cannot find -ltinfo: No such file or directory
collect2: error: ld returned 1 exit status
mojo: error: failed to link executable

```

Which was solved by installing `zlib1g-dev` and `libtinfo-dev`

```sh
sudo apt-get install zlib1g-dev
sudo apt-get install libtinfo-dev

```

Thanks again for the help! and I hope this might help others in the future. 🙂

---

<div class="post-metadata">

**Author:** ![jack.clayton](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/jack.clayton/32/57_2.png) [@jack.clayton](https://forum.modular.com/u/jack.clayton)\
**Post date:** [March 10, 2025, 10:50pm UTC](https://forum.modular.com/t/how-to-make-an-executable/698/4 "2025-03-10T22:50:42Z")

</div>

Hi @AffableHoneyBadger thanks very much for reporting back the fix, they are working on adding these dependencies to the sandboxed environment on Linux so you don’t have to install them yourself. Will reply to this thread when that’s resolved.

---

<div class="post-metadata">

**Author:** ![AffableHoneyBadger](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@AffableHoneyBadger](https://forum.modular.com/u/AffableHoneyBadger)\
**Post date:** [March 10, 2025, 11:08pm UTC](https://forum.modular.com/t/how-to-make-an-executable/698/5 "2025-03-10T23:08:39Z")

</div>

That’s great to hear! Thanks @jack.clayton !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/2751e0fbdc595a99718b216730957e9db4448cfd.jpeg) [@system](https://forum.modular.com/u/system)\
**Post date:** [March 17, 2025, 11:08pm UTC](https://forum.modular.com/t/how-to-make-an-executable/698/6 "2025-03-17T23:08:54Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![ahajha](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@ahajha](https://forum.modular.com/u/ahajha)\
**Post date:** [June 10, 2025, 4:25pm UTC](https://forum.modular.com/t/how-to-make-an-executable/698/7 "2025-06-10T16:25:44Z")

</div>



---

<div class="post-metadata">

**Author:** ![ahajha](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@ahajha](https://forum.modular.com/u/ahajha)\
**Post date:** [June 10, 2025, 4:28pm UTC](https://forum.modular.com/t/how-to-make-an-executable/698/8 "2025-06-10T16:28:25Z")

</div>

Hey @AffableHoneyBadger! Just wanted to mention that in the last few nightlies the requirements for zlib and tinfo have been removed. You will still need `build-essentials`, that is tied into some deeper things that I’m not immediately sure how to resolve. But there should at least be a little less friction now 🙂
