Build Emacs From Source

March 08, 2024

Windows 11 features built-in support for running Linux GUI applications. Emacs 29 has became a real GTK application, gone with the blurry fonts problem.

Firstly, install essential packages in WSL2 Ubuntu 22.04.

apt-get update
apt-get install build-essential libgtk-3-dev libgnutls28-dev libtiff5-dev libgif-dev libjpeg-dev libpng-dev libxpm-dev libncurses-dev texinfo sqlite3 libsqlite3-dev libjansson4 libjansson-dev autoconf

And in Emacs 29, support for tree-sitter is built-in. Now build tree-sitter from source code.

git clone https://github.com/tree-sitter/tree-sitter.git
cd tree-sitter
git checkout v0.21.0
make
make install

Now tree-sitter library has been installed into /usr/local/lib.

export LD_LIBRARY_PATH=/usr/local/lib/

Now build emacs with pgtk and tree-sitter.

git clone https://git.savannah.gnu.org/git/emacs.git -b emacs-29
cd emacs
./autogen.sh
./configure --prefix=/usr/local/emacs --with-pgtk --with-tree-sitter --with-json
make -j 8
make install

You may get some GTK warning on Emacs startup about the GNOME theme, fix this by installing adwaita-icon-theme-full.

apt-get install adwaita-icon-theme-full

Top