This page shows you how to compile emacs on Linux.
Here's how to compile emacs 24 on Linux. It should work for building any emacs version. I assume you are on Ubuntu Linux.
Just do this first:
# install essential build tools sudo apt-get install build-essential # get all dependencies of a previous emacs version sudo apt-get build-dep emacs23
Get source code (http://ftp.gnu.org/gnu/emacs/), then cd to the emacs source dir then
cd ‹source dir name› ./configure make sudo make install # optional. This basically copy the binary to /usr/local/bin
Following is more detailed explanation.
On Ubuntu, typically you install by sudo apt-get install emacs24, where the “emacs24” may be other version. To find out what's the package name, do: apt-cache search emacs | grep emacs.
For latest emacs release, the Linux may not have a prepared package yet.
Possible source for latest version of pre-build emacs packages:
Or, you build it yourself. It's easy.
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 (⁖ 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.
If you haven't done so already, do: sudo apt-get install build-essential. This will install many tools for building.
To see info about the package, do apt-cache showpkg build-essential and 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 emacs23
This will install all packages emacs23 depends on. Here's the output on my machine:
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 ./configure and make again.
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 src/emacs &.
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.
Thanks to Mike Oliver, Christian Lynbech, daniël bosold for inputs.
blog comments powered by Disqus