克隆fcitx-qt5
git clone https://github.com/fcitx/fcitx-qt5.git
修改CmakeLists.txt
修改内容如下
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f9c95af..0e09d8d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,9 +10,9 @@ find_package(ECM 1.4.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
-option(ENABLE_QT5 "Enable Qt5" On)
-option(ENABLE_QT6 "Enable Qt6 im module" Off)
-option(ENABLE_LIBRARY "Qt library" On)
+option(ENABLE_QT5 "Enable Qt5" Off)
+option(ENABLE_QT6 "Enable Qt6 im module" On)
+option(ENABLE_LIBRARY "Qt library" Off)
include(GNUInstallDirs)
include(FeatureSummary)
设置环境变量
然后依次执行如下命令
export PATH=/home/gillbert/Qt/6.7.2/gcc_64/bin/:$PATH
export PATH=/home/gillbert/Qt/Tools/CMake/bin:$PATH
这里需保证Qt版本与Qt Creator中使用的Qt版本一致
开始编译
mkdir build
cd build/
cmake -DQt6_DIR=/home/gillbert/Qt/6.7.2/gcc_64/lib/cmake/ ..
make -j4
遇到的错误
该步骤编译过程中可能会出现如下错误
CMake Error at CMakeLists.txt:9 (find_package):
Could not find a package configuration file provided by "ECM" (requested
version 1.4.0) with any of the following names:
ECMConfig.cmake
ecm-config.cmake
Add the installation prefix of "ECM" to CMAKE_PREFIX_PATH or set "ECM_DIR"
to a directory containing one of the above files. If "ECM" provides a
separate development package or SDK, be sure it has been installed.
解决办法
# 安装需要的依赖包即可
sudo apt install extra-cmake-modules
还可能遇到下面的错误
解决办法
# 安装依赖包
sudo apt-get install libxkbcommon-x11-dev
错误三
解决办法
# 安装依赖的软件包
sudo apt install libgl1-mesa-dev
将编译好后的动态库复制到Qt目录
最后把编译好的libfcitxplatforminputcontextplugin-qt6.so
文件放到
/home/gillbert/Qt/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts
目录下即可
cp qt6/platforminputcontext/libfcitxplatforminputcontextplugin-qt6.so /home/gillbert/Qt/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts