Difference between revisions of "Compiling fcitx5"

From Fcitx
Jump to navigation Jump to search
(Add todo)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''(This article is a work in progress)'''
+
While fcitx5 is provided as a package in many GNU/Linux distributions, some of them (such as Gentoo) don't officially provide it as of May 2020. This article aims to give general instructions on how to compile and install fcitx5 in your GNU/Linux system.
 
 
While fcitx5 is provided as a package in many distributions, some GNU/Linux distributions (such as Gentoo) don't officially provide it as of May 2020. This article aims to give general instructions on how to compile and install fcitx5 in your GNU/Linux system.
 
  
 
== Dependencies ==
 
== Dependencies ==
Line 9: Line 7:
 
* ECM (Extra CMake Modules)
 
* ECM (Extra CMake Modules)
 
* GNU Make
 
* GNU Make
* libxcb ([https://xcb.freedesktop.org/ X protocol C-language Binding])
+
* XCB ([https://xcb.freedesktop.org/ X protocol C-language Binding])
 
* [https://libexpat.github.io/ Expat]
 
* [https://libexpat.github.io/ Expat]
 
* [https://www.freedesktop.org/wiki/Software/pkg-config/ PkgConfig]
 
* [https://www.freedesktop.org/wiki/Software/pkg-config/ PkgConfig]
 
* [https://github.com/json-c/json-c/wiki json-c]
 
* [https://github.com/json-c/json-c/wiki json-c]
 
* dbus
 
* dbus
 +
* [https://fmt.dev fmt]
 
* cldr-emoji-annotation*
 
* cldr-emoji-annotation*
  
Line 27: Line 26:
 
  cmake -DCMAKE_INSTALL_PREFIX=/your/install/path .
 
  cmake -DCMAKE_INSTALL_PREFIX=/your/install/path .
 
Then simply run <code>make</code> and <code>make install</code>.
 
Then simply run <code>make</code> and <code>make install</code>.
 +
Please note that installing to a non-standard path is not recommended.
  
=== cldr-emoji-annotation ===
+
=== cldr-emoji-annotation/unicode-cldr ===
fcitx5 uses these for its emoji module. Some distributions (such as Void Linux) provide this package. Gentoo, on the other hand, does not, but there are user-maintained [https://wiki.gentoo.org/wiki/Ebuild_repository Portage overlays] that provide it such as [https://github.com/microcai/gentoo-zh gentoo-zh]. If you want to build it, [https://github.com/fujiwarat/cldr-emoji-annotation clone the repository] and run <code>./autogen.sh</code>, then <code>./configure</code>, <code>make</code> and <code>make install</code>. It must be installed to the default directory so '''do not set a prefix to the <code>./configure</code> script'''.
+
fcitx5 uses these for its emoji module. Some distributions (such as Void Linux) provide this package. Gentoo, on the other hand, does not, but there are user-maintained [https://wiki.gentoo.org/wiki/Ebuild_repository Portage overlays] that provide it such as [https://github.com/microcai/gentoo-zh gentoo-zh]. If you want to build it, [https://github.com/fujiwarat/cldr-emoji-annotation clone the repository] and run <code>./autogen.sh</code>, then <code>./configure</code>, <code>make</code> and <code>make install</code>. To install it to a custom prefix, run <code>PKG_CONFIG_PATH=$PWD ./configure --prefix=/your/install/path</code> instead (this commands assumes you're in the cldr-emoji-annotation directory).
 +
 
 +
You may also simply disable it with <code>-DENABLE_EMOJI=Off</code>.
  
 
=== fcitx5 ===
 
=== fcitx5 ===
Line 39: Line 41:
 
The user is encouraged to check the contents of CMakeLists.txt for an exhaustive list of options.
 
The user is encouraged to check the contents of CMakeLists.txt for an exhaustive list of options.
  
For example, an [https://i3wm.org/ i3] user who wishes to install it to /opt would run:
+
For example, an [https://i3wm.org/ i3] user who wishes to install it to /opt would run (likely with sudo privileges):
  cmake -DENABLE_WAYLAND=Off -DCMAKE_INSTALL_PREFIX=/opt .
+
  cmake -DENABLE_WAYLAND=Off -DCMAKE_INSTALL_PREFIX=/your/install/path .
 
  make
 
  make
  make install
+
  sudo make install
  
TODO: IM_MODULE envvars
+
=== fcitx5-qt ===
  
=== fcitx5-qt ===
+
fcitx5-qt is the Qt im-module for fcitx5 and it's needed to use fcitx5 with Qt-based applications. It currently supports Qt4 and Qt5. You'll need several Qt modules if you're going to enable Qt5 support, namely QtCore, QtDbus, QtWidgets and QtX11Extras. These usually come bundled in packages on some distributions. For example, on Gentoo you can check what packages include these modules [https://wiki.gentoo.org/wiki/Project:Qt/Qt5status here].
  
TODO
+
Clone [https://github.com/fcitx/fcitx5-qt/ the repository]. Relevant CMake options are '''ENABLE_QT4''' and '''ENABLE_QT5'''. Both are turned on by default. You might want to turn off the flag related to the Qt version you aren't using. Then run <code>cmake</code> with the appropriate options,<code>make</code> and <code>make install</code> as usual. Please note that fcitx5-qt expects to be installed to the same prefix as the fcitx5 core.
  
 
=== fcitx5-gtk ===
 
=== fcitx5-gtk ===
 +
The usual cmake/make/make install building process follows. If you enable [https://wiki.gnome.org/Projects/GObjectIntrospection GObject Introspection] (via the ENABLE_GIR CMake variable), <code>make install</code> will install some files to the system's GIR directories regardless of what CMAKE_INSTALL_PREFIX is set to.
 +
 +
If you have installed it to a custom prefix, you'll need to update the GTK input method module cache. This is done by invoking <code>gtk-query-immodules-3.0</code> (or <code>gtk-query-immodules-2.0</code> for GTK 2) and setting GTK_PATH to point at fcitx5-gtk's GTK library install path beforehand. For example:
 +
 +
GTK_PATH=/your/install/path/lib/gtk-3.0 gtk-query-immodules-3.0 --update-cache
  
TODO
+
=== Input Methods ===
 +
For Mozc, please check [[Special:MyLanguage/Compiling Mozc|Compiling Mozc]].
 +
 
 +
Same procedure applies to input method addons like fcitx5-chinese-addons. but you likely want to make sure it's using the same prefix as fcitx5. Usually there is no cmake options needed, the most common one is to enable the GUI or not. You may look into the CMakeLists.txt in the root directory and look for <code>option(....)</code> lines.
 +
 
 +
cmake -DCMAKE_INSTALL_PREFIX=/your/install/path .
 +
make
 +
sudo make install

Latest revision as of 15:21, 21 December 2022

While fcitx5 is provided as a package in many GNU/Linux distributions, some of them (such as Gentoo) don't officially provide it as of May 2020. This article aims to give general instructions on how to compile and install fcitx5 in your GNU/Linux system.

Dependencies

Note that most of these packages are usually provided by many distributions. cldr-emoji-annotation is a special case and will be covered in the next section.

Building process

xcb-imdkit

After installing all the dependencies, the first thing to do is install xcb-imdkit, an implementation of the X Input Method in XCB. Clone the GitHub repository:

git clone https://github.com/fcitx/xcb-imdkit.git

cd into the Git directory and run cmake:

cmake .

To install it to a custom directory, set the CMAKE_INSTALL_PREFIX flag:

cmake -DCMAKE_INSTALL_PREFIX=/your/install/path .

Then simply run make and make install. Please note that installing to a non-standard path is not recommended.

cldr-emoji-annotation/unicode-cldr

fcitx5 uses these for its emoji module. Some distributions (such as Void Linux) provide this package. Gentoo, on the other hand, does not, but there are user-maintained Portage overlays that provide it such as gentoo-zh. If you want to build it, clone the repository and run ./autogen.sh, then ./configure, make and make install. To install it to a custom prefix, run PKG_CONFIG_PATH=$PWD ./configure --prefix=/your/install/path instead (this commands assumes you're in the cldr-emoji-annotation directory).

You may also simply disable it with -DENABLE_EMOJI=Off.

fcitx5

You should now be able to build fcitx5. Clone the repository. Some cmake options to keep in mind before building are:

  • ENABLE_WAYLAND: Wayland support. Defaults to On and should be fine for desktop environments such as KDE and GNOME. Users running X11-based window managers will need to turn it off.
  • ENABLE_ENCHANT: Enchant support. Defaults to On. Used for word prediction (hinting). Depends on libenchant, which is provided by most distributions.

The user is encouraged to check the contents of CMakeLists.txt for an exhaustive list of options.

For example, an i3 user who wishes to install it to /opt would run (likely with sudo privileges):

cmake -DENABLE_WAYLAND=Off -DCMAKE_INSTALL_PREFIX=/your/install/path .
make
sudo make install

fcitx5-qt

fcitx5-qt is the Qt im-module for fcitx5 and it's needed to use fcitx5 with Qt-based applications. It currently supports Qt4 and Qt5. You'll need several Qt modules if you're going to enable Qt5 support, namely QtCore, QtDbus, QtWidgets and QtX11Extras. These usually come bundled in packages on some distributions. For example, on Gentoo you can check what packages include these modules here.

Clone the repository. Relevant CMake options are ENABLE_QT4 and ENABLE_QT5. Both are turned on by default. You might want to turn off the flag related to the Qt version you aren't using. Then run cmake with the appropriate options,make and make install as usual. Please note that fcitx5-qt expects to be installed to the same prefix as the fcitx5 core.

fcitx5-gtk

The usual cmake/make/make install building process follows. If you enable GObject Introspection (via the ENABLE_GIR CMake variable), make install will install some files to the system's GIR directories regardless of what CMAKE_INSTALL_PREFIX is set to.

If you have installed it to a custom prefix, you'll need to update the GTK input method module cache. This is done by invoking gtk-query-immodules-3.0 (or gtk-query-immodules-2.0 for GTK 2) and setting GTK_PATH to point at fcitx5-gtk's GTK library install path beforehand. For example:

GTK_PATH=/your/install/path/lib/gtk-3.0 gtk-query-immodules-3.0 --update-cache

Input Methods

For Mozc, please check Compiling Mozc.

Same procedure applies to input method addons like fcitx5-chinese-addons. but you likely want to make sure it's using the same prefix as fcitx5. Usually there is no cmake options needed, the most common one is to enable the GUI or not. You may look into the CMakeLists.txt in the root directory and look for option(....) lines.

cmake -DCMAKE_INSTALL_PREFIX=/your/install/path .
make
sudo make install