CentOS 6.5上での emacs 24.3 のビルド

ソースをダウンロードして展開する。

$ curl -O http://ftp.jaist.ac.jp/pub/GNU/emacs/emacs-24.3.tar.gz
$ tar zxvf emacs-24.3.tar.gz
$ cd emacs-24.3/

configure オプションなしの場合、フル機能有りでのビルドとなるため、必要なライブラリをYumでインストールしておく。

INSTALLドキュメントを確認しながら --without-png オプションなどを指定して機能を外していってもいいけど、むしろ面倒なので全部入れる。

$ sudo yum install gtk2-devel libXpm-devel libjpeg-turbo-devel libpng-devel giflib-devel libtiff-devel ncurses-devel
$ ./configure

configure がうまくいったら make

$ make

すると下のようなエラーがでて死にかける。

xsettings.o: In function `something_changed_gsettingsCB':
/home/keik/emacs-24.3/src/xsettings.c:215: undefined reference to `g_settings_get_value'
/home/keik/emacs-24.3/src/xsettings.c:230: undefined reference to `g_settings_get_value'
/home/keik/emacs-24.3/src/xsettings.c:244: undefined reference to `g_settings_get_value'
xsettings.o: In function `init_gsettings':
/home/keik/emacs-24.3/src/xsettings.c:816: undefined reference to `g_settings_list_schemas'
/home/keik/emacs-24.3/src/xsettings.c:822: undefined reference to `g_settings_new'
/home/keik/emacs-24.3/src/xsettings.c:828: undefined reference to `g_settings_get_value'
/home/keik/emacs-24.3/src/xsettings.c:839: undefined reference to `g_settings_get_value'
/home/keik/emacs-24.3/src/xsettings.c:848: undefined reference to `g_settings_get_value'
collect2: ld returned 1 exit status
make[1]: *** [temacs] Error 1
make[1]: Leaving directory `/home/keik/emacs-24.3/src'
make: *** [src] Error 2

対処策としては configure 時に --without-gsettings オプションをつけるといい。(参照)

$ make distclean                     # 掃除
$ ./configure --without-gsettings    # オプション追加
$ make                               # 今度はうまくいく
$ sudo make install                  # ウェイ

(参考) 失敗の原因

メーリングリストをきちんと読んでみると Red HatがGlib2に手を入れている ことが原因らしいことがわかる。

  • The previous rebase to GLib 2.26 added the GSettings API, but without the gsettings-desktop-schemas package. As a consequence, some programs (such as OpenJDK or VMWare) attempted to use GSettings, but since gsettings-desktop-schemas was absent, these programs terminated unexpectedly. This update removes GSettings from glib2, and the crashes now no longer occur. (BZ#1065429)

クソ意訳すると、「GLib2がGSettings APIとかいう実装のないAPIを持ってるせいでOpenJDKが死ぬのでGSettings API削除したった。だからもう泣くな」とのこと。