Ubuntu 24.04 に Emacs 30.2 (with pgtk,xwidgets) をインストール

はじめに

Ubuntu 24.04 に Emacs 30.2 をインストールしました。

インストール環境は下記です。 直近の数バージョンで、バージョンアップがある毎にNative/WSL両方の環境でもビルドしていますので、Native/WSLどちらでも同じ手順で実行できるかと思います。

  • ハードウェア : Core i5-1235U, 32GB Memory, NVMe SSD
  • OS : Windows11 / Ubuntu24.04(WSL)

下記のコンフィギュレーションとなります。

  • pgtk(Pure GTK)
  • native-compilation
  • XWidgets 有効

手順

ソースコードの取得

$ git clone --depth 1 --branch emacs-30.2 git://git.sv.gnu.org/emacs.git emacs-30.2

ビルドに必要なツールとライブラリの取得

libgccjit は 14 を使用します。

$ sudo apt update
$ sudo apt install autoconf make texinfo gnutls-bin libgccjit-14-dev gcc
$ sudo apt install zlib1g-dev \
                   libncurses-dev \
                   libgtk-3-dev \
                   xorg-dev \
                   libjpeg-dev \
                   libgif-dev \
                   libtiff-dev \
                   libgnutls28-dev \
                   librsvg2-dev \
                   libcairo-5c-dev \
                   liblcms2-dev \
                   libgpm-dev \
                   libacl1-dev \
                   libxml2-dev \
                   libotf-dev \
                   libsystemd-dev \
                   libjansson-dev \
                   libsqlite3-dev \
                   imagemagick \
                   libmagickwand-dev \
                   libmagickcore-dev \
                   libtree-sitter-dev \
                   libjansson-dev \
                   libwebkit2gtk-4.1-dev

autogen.sh

configure を生成します。

cd emacs-30.2
./autogen.sh

configureの修正 (xwidgetsを有効にする場合)

configureにて –with-xwidgets を使用する場合、下記のメッセージが表示されるため、configureを書き換えて対応します。

libwebkit2gtk-4.1-dev では、想定しているバージョン(2.41.92)に対して、新しすぎる(2.50.4)ことでエラーになっていますのでこの部分を回避するためです。

checking for webkit2gtk-4.1 >= 2.12 webkit2gtk-4.1 < 2.41.92... no
checking for webkit2gtk-4.0 >= 2.12 webkit2gtk-4.0 < 2.41.92... no
configure: error: xwidgets requested but WebKitGTK+ or WebKit framework not found.

grep -n "2.41.92" configure
22074:    WEBKIT_BROKEN=2.41.92

$ sudo apt list --installed | grep webkit
gir1.2-webkit2-4.1/noble-updates,noble-security,now 2.50.4-0ubuntu0.24.04.1 amd64 [installed,automatic]
libwebkit2gtk-4.1-0/noble-updates,noble-security,now 2.50.4-0ubuntu0.24.04.1 amd64 [installed,automatic]
libwebkit2gtk-4.1-dev/noble-updates,noble-security,now 2.50.4-0ubuntu0.24.04.1 amd64 [installed]

sed -i 's/WEBKIT_BROKEN=2.41.92/WEBKIT_BROKEN=3.0.0/' configure

configureの実行

cd emacs-30.2
./autogen.sh
CFLAGS='-I/usr/lib/gcc/x86_64-linux-gnu/14/include -L/usr/lib/gcc/x86_64-linux-gnu/14' ./configure --with-pgtk --with-native-compilation --without-pop --with-mailutils --with-imagemagick --with-tree-sitter --with-xwidgets

(参考)configure実行時のwarningについて

gtkのチェック

こちらの警告は無視します。

checking for gtk+-3.0 >= 3.22.23 glib-2.0 >= 2.37.5... yes
checking whether GTK compiles... yes
configure: WARNING: Your version of Gtk+ will have problems with
       closing open displays.  This is no problem if you just use
       one display, but if you use more than one and close one of them
       Emacs may crash.
       See https://gitlab.gnome.org/GNOME/gtk/issues/221

試しに、gtk3-dev でなく gtk4-dev をインストールして試した際には下記のエラーが出ていました。

checking for gtk+-3.0 >= 3.22.23 glib-2.0 >= 2.37.5... no
configure: error: Package 'gtk+-3.0', required by 'virtual:world', not found

ですが、そもそも、今回は pgtkビルド(Wayland)を使っているのでほぼ無関係(実害がない)と思われます。

configure結果

Configured for 'x86_64-pc-linux-gnu'.

  Where should the build process find the source code?    .
  What compiler should emacs be built with?               gcc -I/usr/lib/gcc/x86_64-linux-gnu/14/include -L/usr/lib/gcc/x86_64-linux-gnu/14 -O
  Should Emacs use the GNU version of malloc?             no
    (The GNU allocators don't work with this system configuration.)
  Should Emacs use a relocating allocator for buffers?    no
  Should Emacs use mmap(2) for buffer allocation?         no
  What window system should Emacs use?                    pgtk
  What toolkit should Emacs use?                          GTK3
  Where do we find X Windows header files?                Standard dirs
  Where do we find X Windows libraries?                   Standard dirs
  Does Emacs use -lXaw3d?                                 no
  Is Emacs being built for Android?                       no 
  Does Emacs use the X Double Buffer Extension?           no
  Does Emacs use -lXpm?                                   no
  Does Emacs use -ljpeg?                                  yes
  Does Emacs use -ltiff?                                  yes
  Does Emacs use a gif library?                           yes -lgif
  Does Emacs use a png library?                           yes -lpng16 
  Does Emacs use -lrsvg-2?                                yes
  Does Emacs use -lwebp?                                  yes
  Does Emacs use -lsqlite3?                               yes
  Does Emacs use cairo?                                   yes
  Does Emacs use -llcms2?                                 yes
  Does Emacs use imagemagick?                             yes
  Does Emacs use native APIs for images?                  no
  Does Emacs support sound?                               yes
  Does Emacs use -lgpm?                                   yes
  Does Emacs use -ldbus?                                  yes
  Does Emacs use -lgconf?                                 no
  Does Emacs use GSettings?                               yes
  Does Emacs use a file notification library?             yes (inotify)
  Does Emacs use access control lists?                    yes -lacl -lattr
  Does Emacs use -lselinux?                               yes
  Does Emacs use -lgnutls?                                yes
  Does Emacs use -lxml2?                                  yes
  Does Emacs use -lfreetype?                              yes
  Does Emacs use HarfBuzz?                                yes
  Does Emacs use -lm17n-flt?                              
  Does Emacs use -lotf?                                   yes
  Does Emacs use -lxft?                                   
  Does Emacs use -lsystemd?                               yes
  Does Emacs use -ltree-sitter?                           yes
  Does Emacs use the GMP library?                         yes
  Does Emacs directly use zlib?                           yes
  Does Emacs have dynamic modules support?                yes
  Does Emacs use toolkit scroll bars?                     yes
  Does Emacs support Xwidgets?                            yes
  Does Emacs have threading support in lisp?              yes
  Does Emacs support the portable dumper?                 yes
  Does Emacs support legacy unexec dumping?               no
  Which dumping strategy does Emacs use?                  pdumper
  Does Emacs have native lisp compiler?                   yes
  Does Emacs use version 2 of the X Input Extension?      no
  Does Emacs generate a smaller-size Japanese dictionary? no

make

make -j$(nproc)

make install

sudo make install

その他の設定

必要に応じて post-1300 の設定を行います。

おわりに

Ubuntu 24.04 で Emacs 30.2 のビルドおよび起動が確認できました。

Copied title and URL