1.问题描述
麒麟linux系统QtCreator和QtCreator编译的程序无法输入中文,网上找了很多的libfcitxplatforminputcontextplugin.so库都无法使用正常输入;
Qt版本:5.9.6
麒麟系统版本:海光麒麟桌面版kylin V10 SP1 小版本号2203 XC-P923P_KOS_2203_AMD_HG_3250_220630_AUDIT_ACTIVE.iso
2.原因分析
是因为缺少了libfcitxplatforminputcontextplugin.so库的原因,但是要编译这个库设置的Qt版本和你的Qt版本匹配才能正常输入,否则无法输入中文;
网上说将路径/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so
复制到程序路径的platforminputcontexts文件夹下,就可以,但是实际测试不行;网上也找了很多编译过的libfcitxplatforminputcontextplugin.so文件,但是都不行。原因是Qt版本不匹配,导致库不能正常加载,程序打开后,切换到中文输入法,没有响应;所以需要针对具体的Qt版本去重新边编译libfcitxplatforminputcontextplugin.so库;我的Qt版本是5.9.6,编译库的时候也需要指定Qt路径,这就是为什么版本不匹配无法正常加载的原因;
3.解决办法:
按照对应的Qt版本去编译这个库libfcitxplatforminputcontextplugin.so;
下面的连接包含成果物和源码,如果你的Qt版本是5.9.6,可以复制连接下载直接,如果不是可以下载下面的连接源码去设置指定QT版本去编译;
链接:https://pan.baidu.com/s/1zvXWSMHDQEvg5tuiIJYAEA
提取码:关注微信:QStockView,发送麒麟中文,立刻回复给你;
(1)安装cmake
联网直接输入命令:sudo apt-get install cmake 来安装cmake
下载cmake
http://www.cmake.org/cmake/resources/software.html
将Linux版本软件包解压,tar –zxvf cmake-3.26.3-linux-x86_64.tar.gz
重命名解压文件夹未cmake mv cmake-3.26.3-linux-x86_64 cmake
添加系统路径,export PATH=$PATH:/home/hik/soft/cmake/bin
查看cmake是否安装成功,cmake --version
下载fcitx最新版本
https://download.fcitx-im.org/fcitx-qt5/
cd fcitx-qt5
cmake .
make
sudo make install
执行cmake会报如下错误
CMake Error at CMakeLists.txt:8 (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.
-- Configuring incomplete, errors occurred!
遇到上述错误处里方法:
这个页面 https://launchpad.net/ubuntu/+source/extra-cmake-modules/1.4.0-0ubuntu1 下载 extra-cmake-modules_1.4.0.orig.tar.xz
https://launchpad.net/ubuntu/+source/extra-cmake-modules/5.18.0-0ubuntu1 extra-cmake-modules_5.18.0.orig.tar.xz
(2)安装 extra-cmake-modules_1.4.0.orig.tar.xz
如果联网直接用命令:sudo apt-get install extra-cmake-modules
如果不能联网,则解压后执行下面的命令:
cdextra-cmake-modules-1.4.0
cmake .
make
sudomake
install
再次执行fcitx的cmake命令会报如下错误:
- Could NOT find XKBCommon_XKBCommon (missing: XKBCommon_XKBCommon_LIBRARY XKBCommon_XKBCommon_INCLUDE_DIR) (found version "")
CMake Error at /home/hik/soft/cmake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find XKBCommon (missing: XKBCommon_LIBRARIES XKBCommon) (Required
is at least version "0.5.0")
Call Stack (most recent call first):
/home/hik/soft/cmake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
cmake/FindXKBCommon.cmake:30 (find_package_handle_standard_args)
CMakeLists.txt:43 (find_package)
-- Configuring incomplete, errors occurred!
解决办法
联网直接调用sudo apt-get install libxkbcommon-dev
(3)安装libxkbcommon-dev
联网直接调用sudo apt install libxkbcommon-dev
离线下载安装包
wget http://xkbcommon.org/download/libxkbcommon-0.5.0.tar.xz
解压:tar xf libxkbcommon-0.5.0.tar.xz
进入目录:cd libxkbcommon-0.5.0
禁用高版本编译器并生成makefile文件:./configure --disable-x11
编译:make
安装:sudo make install
执行make的时候又报错
YACC src/xkbcomp/parser.c
./build-aux/ylwrap:行176: yacc:未找到命令
make: *** [Makefile:1522:src/xkbcomp/parser.c] 错误 127
解决办法:安装bison
(4)安装Bison
需要yacc的支持。这个工具包含在软件包bison中,联网直接执行命令:sudo apt-get install bison
离线下载
https://pkgs.org/download/bison
麒麟系统选择bison_3.5.1+dfsg-1_amd64.deb
将这个下载地址复制到浏览器后下载文件,复制到电脑上进行安装
http://archive.ubuntu.com/ubuntu/pool/main/b/bison/bison_3.5.1+dfsg-1_amd64.deb
安装命令:sudo dpkg -i bison_3.5.1+dfsg-1_amd64.deb
版本选3.8.2,太高会报如下错误
正在解压 bison (2:3.8.2+dfsg-1build1) ...
dpkg: 依赖关系问题使得 bison 的配置工作不能继续:
bison 依赖于 libc6 (>= 2.34);然而:
系统中 libc6:amd64 的版本为 2.31-0kylin9.1k20.5。
也不能选太低的版本,否则会报错:
准备解压 bison_3.0.4.dfsg-1build1_amd64.deb ...
正在解压 bison (2:3.0.4.dfsg-1build1) 并覆盖 (2:3.8.2+dfsg-1build1) ...
dpkg: 依赖关系问题使得 bison 的配置工作不能继续:
bison 依赖于 libbison-dev (= 2:3.0.4.dfsg-1build1);然而:
未安装软件包 libbison-dev。
(5)继续执行安装libxkbcommon-dev
进入目录:cd libxkbcommon-0.5.0/
编译:make
安装:sudo make install
(6)继续安装fcitx
cd fcitx-qt5-1.2.7/
mkdir build
cd build
cmake ..
报错如下
CMake Error at CMakeLists.txt:46 (find_package):
By not providing "FindFcitx.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Fcitx", but
CMake did not find one.
Could not find a package configuration file provided by "Fcitx" (requested
version 4.2.8) with any of the following names:
FcitxConfig.cmake
fcitx-config.cmake
Add the installation prefix of "Fcitx" to CMAKE_PREFIX_PATH or set
"Fcitx_DIR" to a directory containing one of the above files. If "Fcitx"
provides a separate development package or SDK, be sure it has been
installed.
解决办法增加编译参数
cmake -DENABLE_LIBRARY=false ..
出现如下报错:
CMake Error at qt5/CMakeLists.txt:1 (find_package):
Could not find a package configuration file provided by "Qt5" (requested
version 5.1.0) with any of the following names:
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
to a directory containing one of the above files. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
解决方法:
添加qt环境变量,电脑要安装Qt,这里是Qt的安装路径,关键步骤,指定qt编译环境
export CMAKE_PREFIX_PATH=/home/hik/Qt5.9.6/5.9.6/gcc_64
再次执行cmake命令:
hik@hik-dsvt420rhb:~/soft/fcitx-qt5-1.2.7$ cmake -DENABLE_LIBRARY=false .
出现如下报错:
CMake Error at /home/hik/Qt5.9.6/5.9.6/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message):
Failed to find "GL/gl.h" in "/usr/include/libdrm".
Call Stack (most recent call first):
/home/hik/Qt5.9.6/5.9.6/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:172 (include)
/home/hik/Qt5.9.6/5.9.6/gcc_64/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:89 (find_package)
/home/hik/Qt5.9.6/5.9.6/gcc_64/lib/cmake/Qt5/Qt5Config.cmake:28 (find_package)
qt5/CMakeLists.txt:1 (find_package)
解决方法:
网上查询了一下发现时未安装opengl,于是安装便是了
sudo apt install mesa-common-dev
又出现如下报错:
执行来更新缺少的软件包
sudo apt-get update
sudo apt-get update –fix-missing
然后再执行如下安装命令,就安装成功了;
sudo apt install mesa-common-dev
再次执行cmake -DENABLE_LIBRARY=false ..
在build文件夹会生成makefile文件,进入build目录执行make命令出现如下错误error: no matching function for call to ‘QMetaObject::invokeMethod(QFcitxPlatformInputContext*, QFcitxPlatformInputContext::setFocusObject(QObject*)::<lambda()>, Qt::ConnectionType)
从这里下载替换的qfcitxplatforminputcontext.cpp 和qfcitxplatforminputcontext.h文件,替换到路径/soft/fcitx-qt5-1.2.7/qt5/platforminputcontext
https://url25.ctfile.com/f/34628125-616663558-6a6901?p=3005 (访问密码: 3005)
最后执行make就会生成so文件
已经编译好的库文件下载链接如下,包含源码,如果使用Qt版本不匹配,需要重新用源码编译,
链接:https://pan.baidu.com/s/1zvXWSMHDQEvg5tuiIJYAEA
提取码:关注微信:QStockView,发送麒麟中文,立刻回复给你;
(7)将soft/fcitx-qt5-1.2.7/build/qt5/platforminputcontext路径下生成的库文件复制到你的程序目录platforminputcontexts下面,就可以输入中文了;
(8)将库文件复制到如下Qt安装路径,然后重新打开Qtcreator,使得Qtcreator能够输入中文
/home/hik/Qt5.9.6/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts
/home/hik/Qt5.9.6/5.9.6/gcc_64/plugins/platforminputcontexts
标签:cmake,Qt,1.2,package,sudo,编译,QtCreator,bison,find From: https://www.cnblogs.com/bclshuai/p/17453433.html