This page shows you how to compile/build emacs on Linux. I assume you are on Ubuntu Linux.
If you want to build latest development version, see: How to Build Emacs from git Repository.
Here's summary of what to do.
① Install essential build tools and dependency first:
# install essential build tools sudo apt-get install build-essential
② Download emacs dependencies:
# get all dependencies of a previous emacs version sudo apt-get build-dep emacs24
③ Download emacs source code from http://ftp.gnu.org/gnu/emacs/, then cd to the emacs source directory.
④ Compile emacs:
cd ‹source_dir_name› ./configure make
Now, the emacs binary is at
source_dir_name/src/emacs. You can start that now.
Optionally, now you can copy to the proper directories.
sudo make install # optional. This basically copy the binary to /usr/local/bin
Following is detailed explanation.
On Ubuntu, typically you install by
sudo apt-get install emacs24, where the “emacs24” may be other version.
To search for emacs, do:
apt-cache search emacs | grep emacs.
When emacs has a new version, Ubuntu Linux typically takes half a year to a year to have a prepared package.
Or, you build it yourself. It's easy.
Download emacs source code here: http://ftp.gnu.org/gnu/emacs/
To compile programs on unix, typically the steps are:
cd ‹source_dir_name› ./configure make sudo make install # optional. This basically copy the binary to /usr/local/bin
In the source dir, there's usually a README or INSTALL file.
However, you'll probably fail in the configure step, because emacs requires lots other libraries, also, you might be missing build tools.
Here's some sample output of failure:
checking for libXaw... configure: error: No X toolkit could be found. If you are sure you want Emacs compiled without an X toolkit, pass --with-x-toolkit=no to configure. Otherwise, install the development libraries for the toolkit that you want to use (➢ for example: Gtk+) and re-run configure.
configure: error: The following required libraries were not found: libXpm libjpeg libpng libgif/libungif libtiff Maybe some development libraries/packages are missing? If you don't want to link with them give --with-xpm=no --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no as options to configure
configure: error: The required function `tputs' was not found in any library. These libraries were tried: 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.
You can type
./configure --help to see the options it supports.
See its output here: linux_compile_emacs_24_config_help_output.txt.
# install basic build tools sudo apt-get install build-essential
To see info about the package, do:
apt-cache showpkg build-essential
apt-cache show build-essential
You'll need to install some 30 dependent libraries. The trick is to know which are they. Took me a couple hours to find out the hard way.
The easiest way is to install all dependencies of a previous version of the package, like this:
sudo apt-get build-dep emacs24
This will install all packages emacs24 depends on.
Here's the output on my machine for emacs23:
The following NEW packages will be installed: autoconf automake autotools-dev bsd-mailx diffstat imagemagick libasound2-dev libdatrie-dev libdbus-1-dev libgconf2-dev libgpm-dev libgtk2.0-dev liblockfile-dev liblqr-1-0 libm17n-dev libmagickcore3 libmagickwand3 libncurses5-dev libotf-dev librsvg2-dev libthai-dev libtinfo-dev libxml2-dev postfix quilt sharutils texinfo xaw3dg xaw3dg-dev xutils-dev 0 upgraded, 30 newly installed, 0 to remove and 4 not upgraded. Need to get 12.4 MB of archives. After this operation, 49.5 MB of additional disk space will be used.
You can see the full bash output here: linux_compile_emacs_23_dependencies.txt
make distclean to clear files created by configure.
Once you have all the dependencies, you can now run
Here's a sample successful output:
After successful “make”, you should have a binary at
src/emacs in the current dir. You can test run it by
Optionally, you can do
sudo make install, which will basically copy the binary to
/user/loca/bin/, and copy various elisp files, info files, man pages, etc, into various Linux default dirs.