Wednesday, February 07, 2018

Build emacs from source (CentOS/RHEL 7)


I often have development systems where I need my favorite editor: Emacs Live. Since Emacs Live requires Emacs 24.4+, and as of writing the latest version in the standard yum repositories is 24.3, rather than fish around for a potentially dangerous RPM, I strongly prefer to build from source.

Most of my remote development hosts do not typically have a build chain installed, so to set one up:

sudo yum group install "Development Tools"

Download and extract the intended Emacs sources, e.g.:

wget http://mirror.clarkson.edu/gnu/emacs/emacs-25.3.tar.gz
tar xvf emacs-25.3.tar.gz

Configure the build:

cd emacs-25.3
./configure
# use --with-x=no with configure to exclude the X11 UI from the build, which is ideal for text-only remote systems

I often, however, run into the following:

...
configure: error: The required function 'tputs' was not found in any library.
The following libraries were tried (in order):
  libtinfo, libncurses, libterminfo, libtermcap, libcurses
Please try installing whichever of these libraries is most appropriate
for your system, together with its header files.

For example, a libncurses-dev(el) or similar package.

Which can be fixed by installing ncurses:

sudo yum install ncurses-devel

Retry the configure step:

./configure --with-x=no

And proceed to build:

make
sudo make install

Finally, launch (with high color terminal):

export TERM=xterm-256color && emacs