Building Native Emacs in Ubuntu 20.04 or 21.04

I’ve been using native emacs for while now. I love it. So much faster than its interpreted counterpart.

Building it is still a bit tricky though. I’ve used this basic process on WSL2 and on a headless server to compile without X11 support.

The general build guide on emacswiki is very good and has a lot of platform-specific instructions.

Start by cloning the repo. You don’t need 300MB of history, do you? Use the git –depth 1 option for a shallow clone.

git clone --depth 1 git://
cd emacs

Next install some dependencies. You’ll have more or less of these depending on what’s already installed.

texinfo zlib1g-dev gcc-10 g++-10 libgnutls28-dev libncurses5-dev

libgccjit can’t be used older versions of gcc so I needed to export the newer gcc versions

export CC=/usr/bin/gcc-10 CXX=/usr/bin/gcc-10

Super strange but the gnutls dev library wouldn’t configure correctly in WSL Ubutu 20 or headless Ubuntu 18.

sudo apt-get install pkg-config
pkg-config --cflags gnutls

You should be ready to build now.

./configure --with-native-compilation --with-x-toolkit=no --with-xpm=ifavailable --with-jpeg=ifavailable --with-png=ifavailable
 --with-gif=ifavailable --with-tiff=ifavailable

Clean up any remaining dependency issues you have with ./configure, then fire up Make.

make -j[your # of cores goes here]

If the binary built correctly you should be able to run native emacs now! Try to run it:


If it starts up and shows the latest emacs version, you did it. Go ahead and uninstall your old version then install with:

make install

Leave a Comment