Building 4coder for Mac

07.20.2022
BLOG

This is going to be a pretty utilitarian post on how to build 4coder for Mac.

Why?

4coder is incredible - and more importantly, it’s what I want to be using whenever I’m typing code. I had to move to an M2 Mac recently and the pre-built versions of 4coder don’t work on an M2 chip.

Allen recently open sourced 4coder putting the code on github. But, as the README notes, support of Mac hasn’t been updated in some time. I suspect, in fact, that there never was support for M2 Macs at all.

So I started trying to get it to work on Mac again, specifically on an M2 chip. It’s surprisingly easy, even though it took me a while to figure out how to do it.

What follows below is how I accomplished this. While I haven’t tested it on Intel macs, I believe many of the steps below will need to be done if you want to build 4coder for a non-M2 chips computer as well.

Building 4coder

1. GET THE CODE:

Follow the steps in the README of the git repo up until step 7 (where you run the various build scripts) The git repo is here:

https://github.com/dion-systems/4coder

2. REALPATH:

The build scripts make use of a tool called realpath. This is standard on linux it seems but is not included on Macs. You can get realpath by doing one of the following:

3. FREETYPE:

The 4coder-non-source repo has prebuild libraries for freetype. Those libraries are built for Macs running on Intel chips.

4. IMMINTRIN ISSUES:

Compiling on an M2 chip, I got a bunch of errors relating to intrinsics/assembly code in the 4coder_audio.h/c files. I personally don’t rely on 4coder for audio so I chose to just omit this code from compilation.

  1. cd into 4ed/code
  2. run bin/build-mac.sh

And you should be good to go! Let me know if this doesn’t work for you, and I’ll update instructions here.