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/464648

相关文章

C++右移运算符的一个小坑及解决

《C++右移运算符的一个小坑及解决》文章指出右移运算符处理负数时左侧补1导致死循环,与除法行为不同,强调需注意补码机制以正确统计二进制1的个数... 目录我遇到了这么一个www.chinasem.cn函数由此可以看到也很好理解总结我遇到了这么一个函数template<typename T>unsigned

Python使用FastAPI实现大文件分片上传与断点续传功能

《Python使用FastAPI实现大文件分片上传与断点续传功能》大文件直传常遇到超时、网络抖动失败、失败后只能重传的问题,分片上传+断点续传可以把大文件拆成若干小块逐个上传,并在中断后从已完成分片继... 目录一、接口设计二、服务端实现(FastAPI)2.1 运行环境2.2 目录结构建议2.3 serv

Spring Security简介、使用与最佳实践

《SpringSecurity简介、使用与最佳实践》SpringSecurity是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架,本文给大家介绍SpringSec... 目录一、如何理解 Spring Security?—— 核心思想二、如何在 Java 项目中使用?——

springboot中使用okhttp3的小结

《springboot中使用okhttp3的小结》OkHttp3是一个JavaHTTP客户端,可以处理各种请求类型,比如GET、POST、PUT等,并且支持高效的HTTP连接池、请求和响应缓存、以及异... 在 Spring Boot 项目中使用 OkHttp3 进行 HTTP 请求是一个高效且流行的方式。

Java使用Javassist动态生成HelloWorld类

《Java使用Javassist动态生成HelloWorld类》Javassist是一个非常强大的字节码操作和定义库,它允许开发者在运行时创建新的类或者修改现有的类,本文将简单介绍如何使用Javass... 目录1. Javassist简介2. 环境准备3. 动态生成HelloWorld类3.1 创建CtC

使用Python批量将.ncm格式的音频文件转换为.mp3格式的实战详解

《使用Python批量将.ncm格式的音频文件转换为.mp3格式的实战详解》本文详细介绍了如何使用Python通过ncmdump工具批量将.ncm音频转换为.mp3的步骤,包括安装、配置ffmpeg环... 目录1. 前言2. 安装 ncmdump3. 实现 .ncm 转 .mp34. 执行过程5. 执行结

Java使用jar命令配置服务器端口的完整指南

《Java使用jar命令配置服务器端口的完整指南》本文将详细介绍如何使用java-jar命令启动应用,并重点讲解如何配置服务器端口,同时提供一个实用的Web工具来简化这一过程,希望对大家有所帮助... 目录1. Java Jar文件简介1.1 什么是Jar文件1.2 创建可执行Jar文件2. 使用java

C#使用Spire.Doc for .NET实现HTML转Word的高效方案

《C#使用Spire.Docfor.NET实现HTML转Word的高效方案》在Web开发中,HTML内容的生成与处理是高频需求,然而,当用户需要将HTML页面或动态生成的HTML字符串转换为Wor... 目录引言一、html转Word的典型场景与挑战二、用 Spire.Doc 实现 HTML 转 Word1

Java中的抽象类与abstract 关键字使用详解

《Java中的抽象类与abstract关键字使用详解》:本文主要介绍Java中的抽象类与abstract关键字使用详解,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、抽象类的概念二、使用 abstract2.1 修饰类 => 抽象类2.2 修饰方法 => 抽象方法,没有

MyBatis ParameterHandler的具体使用

《MyBatisParameterHandler的具体使用》本文主要介绍了MyBatisParameterHandler的具体使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参... 目录一、概述二、源码1 关键属性2.setParameters3.TypeHandler1.TypeHa