2023-12-03-解决libxkbcommon库编译完后图像界面不能使用键盘

本文主要是介绍2023-12-03-解决libxkbcommon库编译完后图像界面不能使用键盘,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


layout: post # 使用的布局(不需要改)
title: Ubuntu修复 # 标题
subtitle: 解决libxkbcommon库编译完图形界面不能使用键盘 #副标题
date: 2023-12-03 # 时间
author: BY ThreeStones1029 # 作者
header-img: img/about_bg.jpg #这篇文章标题背景图片
catalog: true # 是否归档
tags: Ubuntu #标签


文章目录

  • 一、前言
  • 二、(临时解决方案)更换图形界面
    • 2.1.安装lightdm图形管理器
    • 2.2.切换图形管理器
    • 2.3.安装unity桌面
    • 2.4.图形界面美化
  • 三、问题依旧存在
    • 3.1.下载fcitx-qt5
    • 3.2.安装extra-cmake-modules
    • 3.3.安装libxkbcommon
    • 3.4.总结
  • 四、最终解决方法
  • 五、待解决的问题
    • 5.1.新出现的问题
    • 5.2.我的解决方案
  • 六、参考资料

一、前言

上个礼拜在qt界面不能输入中文,所以按照一些博客编译libfcitxplatforminputcontextplugin.so库,编译完后发现我的qt直接不能使用键盘了,使用键盘就会直接闪退然后,我尝试去重启后我发现我的图形界面直接崩溃,图形界面打不开了,只有左上角一个光标在闪。

二、(临时解决方案)更换图形界面

在不能打开桌面后,我尝试了很多办法,在stackoverflow,github、ubuntu官网都没有找到解决方案。不得已我当务之急是想恢复我的桌面,所以我安装了unity桌面,同时更换了lightdm图形管理器,才恢复我的图形界面。

2.1.安装lightdm图形管理器

sudo apt-get install lightdm

2.2.切换图形管理器

sudo dpkg-reconfigure lightdm

运行完后会需要选择图形管理器,选择lightdm,选择完后可以使用

cat /etc/x11/default-display-manager

查看当前图形管理器,是否切换成功

2.3.安装unity桌面

sudo apt-get install unity

然后重启就会能进图形管理器了。

2.4.图形界面美化

如果觉得图形界面不好看,可以安装unity-tweak-tools

sudo apt-get install unity-tweak-tools

打开命令

unity-tweak-tools

如果报错schema com.canonical.Unity.ApplicationsLens not installed

需要安装unity-lens-applications、unity-lens-files

sudo apt-get install unity-lens-applications
sudo apt-get install unity-lens-files

安装完可以选用主题等

三、问题依旧存在

虽然有了图形界面,但我依旧发现qt不能使用键盘,同时发现我的cmake、slicer都不能使用键盘了,只要键盘有输入就会闪退。

问题似乎更严重了,我重新回忆了当时的安装过程。由于已经过去了一周,所以可能有遗漏,当时我的编译安装过程如下:

3.1.下载fcitx-qt5

然后解压后在根目录新建build

cd /build
cmake ..
make
make install

3.2.安装extra-cmake-modules

CMake Error at CMakeLists.txt:49 (find_package):By not providing "FindFcitx5Utils.cmake" in CMAKE_MODULE_PATH this projecthas asked CMake to find a package configuration file provided by"Fcitx5Utils", but CMake did not find one.Could not find a package configuration file provided by "Fcitx5Utils"(requested version 5.0.16) with any of the following names:Fcitx5UtilsConfig.cmakefcitx5utils-config.cmakeAdd the installation prefix of "Fcitx5Utils" to CMAKE_PREFIX_PATH or set"Fcitx5Utils_DIR" to a directory containing one of the above files.  If"Fcitx5Utils" provides a separate development package or SDK, be sure ithas been installed.-- Configuring incomplete, errors occurred!

查找后发现需要安装extra-cmake-modules

所以下载extra-cmake-modules_1.4.0.orig.tar.xz,和上面一样安装

cmake .
make
make install

发现报错

[ 50%] sphinx-build html: see /home/jjf/Downloads/extra-cmake-modules_1.4.0.orig/extra-cmake-modules-1.4.0/docs/build-html.log
Traceback (most recent call last):File "/home/jjf/anaconda3/bin/sphinx-build", line 7, in <module>from sphinx.cmd.build import main
ModuleNotFoundError: No module named 'sphinx'
make[2]: *** [docs/CMakeFiles/documentation.dir/build.make:62: docs/doc_format_html] Error 1
make[1]: *** [CMakeFiles/Makefile2:175: docs/CMakeFiles/documentation.dir/all] Error 2
make: *** [Makefile:163: all] Error 2Extension error:
Could not import extension ecm (exception: cannot import name 'htmlescape' from 'sphinx.util.pycompat' (/home/jjf/anaconda3/lib/python3.7/site-packages/sphinx/util/pycompat.py))
make[2]: *** [docs/CMakeFiles/documentation.dir/build.make:62: docs/doc_format_html] Error 2
make[1]: *** [CMakeFiles/Makefile2:175: docs/CMakeFiles/documentation.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

然后按照这个链接解决完这个报错

https://github.com/KDE/extra-cmake-modules/commit/001f901ee297bb5346729a02e8920b7528e20717

3.3.安装libxkbcommon

继续重新编译fcitx-qt5发现报错

 “Could NOT find XKBCommon_XKBCommon (missing: XKBCommon_XKBCommon_LIBRARY XKBCommon_XKBCommon_INCLUDE_DIR) (found version "")

这时需要安装libxkbcommon库,我安装的是libxkbcommon0.5.0

./configure --disable-x11
make
sudo make install

重点注意:在我安装完libxkbcommon0.5.0,但这是我图形界面崩溃埋的伏笔

重新编译发现,我的fcitx-qt5编译成功

-- The following OPTIONAL packages have been found:* PkgConfig-- The following REQUIRED packages have been found:* ECM (required version >= 1.4.0)* XKBCommon (required version >= 0.5.0), Keyboard handling library using XKB data, <http://xkbcommon.org>* Qt5DBus* Qt5Widgets* Qt5Concurrent* Qt5 (required version >= 5.1.0)* Qt5Gui (required version >= 5.1.0)* Qt5Core-- Configuring done
-- Generating done
-- Build files have been written to: /home/jjf/Downloads/fcitx-qt5/build
(base) jjf@jjf-Precision-Tower-7810:~/Downloads/fcitx-qt5/build$ make
Scanning dependencies of target fcitxplatforminputcontextplugin_autogen
[  4%] Automatic MOC for target fcitxplatforminputcontextplugin
[  4%] Built target fcitxplatforminputcontextplugin_autogen
[  9%] Generating inputmethod1proxy.cpp, inputmethod1proxy.h
[ 14%] Generating inputcontextproxy.cpp, inputcontextproxy.h
[ 19%] Generating inputcontextproxy.moc
[ 23%] Generating inputcontext1proxy.cpp, inputcontext1proxy.h
[ 28%] Generating inputcontext1proxy.moc
[ 33%] Generating inputmethodproxy.cpp, inputmethodproxy.h
[ 38%] Generating inputmethodproxy.moc
[ 42%] Generating inputmethod1proxy.moc
Scanning dependencies of target fcitxplatforminputcontextplugin
[ 47%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/fcitxplatforminputcontextplugin_autogen/mocs_compilation.cpp.o
[ 52%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/fcitxinputcontextproxy.cpp.o
[ 57%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/fcitxqtdbustypes.cpp.o
[ 61%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/fcitxwatcher.cpp.o
[ 66%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/qfcitxplatforminputcontext.cpp.o
[ 71%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/main.cpp.o
[ 76%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/qtkey.cpp.o
[ 80%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/inputcontextproxy.cpp.o
[ 85%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/inputcontext1proxy.cpp.o
[ 90%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/inputmethodproxy.cpp.o
[ 95%] Building CXX object qt5/platforminputcontext/CMakeFiles/fcitxplatforminputcontextplugin.dir/inputmethod1proxy.cpp.o
[100%] Linking CXX shared module libfcitxplatforminputcontextplugin.so
[100%] Built target fcitxplatforminputcontextplugin
(base) jjf@jjf-Precision-Tower-7810:~/Downloads/fcitx-qt5/build$ sudo make install
[sudo] password for jjf: 
[  4%] Automatic MOC for target fcitxplatforminputcontextplugin
[  4%] Built target fcitxplatforminputcontextplugin_autogen
[100%] Built target fcitxplatforminputcontextplugin
Install the project...
-- Install configuration: ""
-- Installing: /opt/Qt5.14.2/5.14.2/gcc_64/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so
-- Set runtime path of "/opt/Qt5.14.2/5.14.2/gcc_64/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so" to ""

然而我加入了对应的libfcitxplatforminputcontextplugin.so库后,发现我的qt直接闪退。然后我去掉libfcitxplatforminputcontextplugin.so库,也没有效果。然后我重启了!!!,就是因为这一重启,我图形界面直接进不去了,图形界面直接崩溃。

我查看了系统日志

tail -f /var/log/syslog

发现了这一条:

segfault at 4 ip 00007fe31c7c5fe8 sp 00007ffdd5ab6480 error 4 in libxkbcommon.so.0.0.0[7fe31c7ad000+1b000]

这期间让我注意到libxkbcommon.so.0.0.0正是我前面编译过的库,所以我确定就是因为我编译了libxkbcommon导致图形界面崩溃。

3.4.总结

以上大体就是我的libfcitxplatforminputcontextplugin.so库编译安装过程,可能由于时间原因,我很难复现,但大体是这样的。期间第一个错误就是编译了libxkbcommon库,其次就是重启了。

四、最终解决方法

前面提到我临时安装了unity的桌面以及ibus的输入法(因为在拯救过程中卸载了fcitx)暂时解决桌面图形界面的问题。但还是qt、cmake、slicer都不能使用键盘。qt、cmake重新安装都没有解决闪退问题。

我昨天上午尝试回忆了当天libfcitxplatforminputcontextplugin.so库的编译过程,思来想起觉得最大的错误是编译的libxkbcommon库版本不对,导致与我的系统冲突(ubuntu20.04)。

所以我重新下载安装了libxkbcommon0.8.4,编译完成libxkbcommon发现我的qt以及cmake,slicer都可以使用键盘了。我意识到问题可能解决了,然后我尝试把桌面换回来。

果不其然,桌面可以使用默认桌面了,gdm3图形管理器也可以使用了。

我有在libxkbcommon的官方github上提过这个问题,但是似乎没有人遇到过。

https://github.com/xkbcommon/libxkbcommon/issues/412

五、待解决的问题

5.1.新出现的问题

但是,一波三折,虽然默认桌面可以使用,qt、cmake等软件可以使用键盘了。但我很快发现了我的键盘的super键一直处于按下的状态,不能正常的输入。数字键直接变成快捷键了,我很快意识到仿佛输入法按键被交换了,super键需要一直按着才能正常输入。

我在stackoverflow,github,ubuntu官网都没有找到解决方法,期间看到类似的问题,ubuntu官网上有人说可以在gnome-tweaks的dash to panel里面修改,安装这个工具后但是我发现我的设置是正常的,没有设置错误热键。[gnome - Number keys switching applications (Ubuntu 21.10) - Ask Ubuntu],这种方法对我无效。

5.2.我的解决方案

我尝试将默认输入法替换为了ibus输入法(因为默认桌面似乎默认使用fcitx输入法),同时替换了默认桌面为unity的桌面。然后惊奇的发现可以使用键盘了,super键不再被默认按着。

但是在默认桌面下不管怎么样,我的键盘super仿佛被一支无形的手按着。

感觉还是因为输入法的原因导致键盘热键冲突,但目前使用unity桌面+ibus输入法能够满足我的需求,所以我没有深究下去,如果后续有了更好的解决方案,我会及时更新的。

六、参考资料

有些资料和博客因为没有及时记录下来,以下是我目前记得的一些

1.解决Ubuntu下安装Qt5.8无法输入中文的问题

2.ModuleNotFoundError: No module named ‘sphinx’

3.extra-cmake-modules_1.4.0.orig.tar.xz

4.xkbcommon官网

5.我在xkbcommon的github提的issue

6.ubuntu官网提到的解决super按键方法

7.fcitx-qt5官网

8.ubuntu 20.04安装 unity-tweak-tools 启动时遇到错误

9.查看与切换Ubuntu显示管理器

10.Ubuntu进不去图形化界面的解决方案

11.Ubuntu开机没有图形界面 进入tty的拯救方法
也可以到我的个人博客查看,有时会来不及同步更新到CSDN

这篇关于2023-12-03-解决libxkbcommon库编译完后图像界面不能使用键盘的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/450629

相关文章

Python虚拟环境终极(含PyCharm的使用教程)

《Python虚拟环境终极(含PyCharm的使用教程)》:本文主要介绍Python虚拟环境终极(含PyCharm的使用教程),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录一、为什么需要虚拟环境?二、虚拟环境创建方式对比三、命令行创建虚拟环境(venv)3.1 基础命令3

Python Transformer 库安装配置及使用方法

《PythonTransformer库安装配置及使用方法》HuggingFaceTransformers是自然语言处理(NLP)领域最流行的开源库之一,支持基于Transformer架构的预训练模... 目录python 中的 Transformer 库及使用方法一、库的概述二、安装与配置三、基础使用:Pi

关于pandas的read_csv方法使用解读

《关于pandas的read_csv方法使用解读》:本文主要介绍关于pandas的read_csv方法使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录pandas的read_csv方法解读read_csv中的参数基本参数通用解析参数空值处理相关参数时间处理相关

使用Node.js制作图片上传服务的详细教程

《使用Node.js制作图片上传服务的详细教程》在现代Web应用开发中,图片上传是一项常见且重要的功能,借助Node.js强大的生态系统,我们可以轻松搭建高效的图片上传服务,本文将深入探讨如何使用No... 目录准备工作搭建 Express 服务器配置 multer 进行图片上传处理图片上传请求完整代码示例

SpringBoot条件注解核心作用与使用场景详解

《SpringBoot条件注解核心作用与使用场景详解》SpringBoot的条件注解为开发者提供了强大的动态配置能力,理解其原理和适用场景是构建灵活、可扩展应用的关键,本文将系统梳理所有常用的条件注... 目录引言一、条件注解的核心机制二、SpringBoot内置条件注解详解1、@ConditionalOn

Python中使用正则表达式精准匹配IP地址的案例

《Python中使用正则表达式精准匹配IP地址的案例》Python的正则表达式(re模块)是完成这个任务的利器,但你知道怎么写才能准确匹配各种合法的IP地址吗,今天我们就来详细探讨这个问题,感兴趣的朋... 目录为什么需要IP正则表达式?IP地址的基本结构基础正则表达式写法精确匹配0-255的数字验证IP地

OpenCV图像形态学的实现

《OpenCV图像形态学的实现》本文主要介绍了OpenCV图像形态学的实现,包括腐蚀、膨胀、开运算、闭运算、梯度运算、顶帽运算和黑帽运算,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起... 目录一、图像形态学简介二、腐蚀(Erosion)1. 原理2. OpenCV 实现三、膨胀China编程(

使用Python实现全能手机虚拟键盘的示例代码

《使用Python实现全能手机虚拟键盘的示例代码》在数字化办公时代,你是否遇到过这样的场景:会议室投影电脑突然键盘失灵、躺在沙发上想远程控制书房电脑、或者需要给长辈远程协助操作?今天我要分享的Pyth... 目录一、项目概述:不止于键盘的远程控制方案1.1 创新价值1.2 技术栈全景二、需求实现步骤一、需求

Spring LDAP目录服务的使用示例

《SpringLDAP目录服务的使用示例》本文主要介绍了SpringLDAP目录服务的使用示例... 目录引言一、Spring LDAP基础二、LdapTemplate详解三、LDAP对象映射四、基本LDAP操作4.1 查询操作4.2 添加操作4.3 修改操作4.4 删除操作五、认证与授权六、高级特性与最佳

Qt spdlog日志模块的使用详解

《Qtspdlog日志模块的使用详解》在Qt应用程序开发中,良好的日志系统至关重要,本文将介绍如何使用spdlog1.5.0创建满足以下要求的日志系统,感兴趣的朋友一起看看吧... 目录版本摘要例子logmanager.cpp文件main.cpp文件版本spdlog版本:1.5.0采用1.5.0版本主要