國產化麒麟linux系統QtCreator和QtCreator編譯的程序無法輸入中文libfcitx最新版本編譯1.2.7

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

如果不能聯網,則解壓後執行下面的命令:

cd extra-cmake-modules-1.4.0
cmake .
make
sudo make 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章