最近在ubantu上使用Qt开发进行开发,遇到不能使用输入法输入中文的问题,有点头疼,于是百度谷歌双管齐下,查阅各方资料,综合各种解决方案,kill 了这个问题,在此做下笔记,也希望能够帮助到同样遇到此问题的人。
系统版本: ubantu 16.04 LTS
输入法: 搜狗输入法
本人Qt版本: Qt5.6
解决方法,编译 fcitx-qt5 源码
1.1 前期准备工作
sudo apt-get install cmake
(2) 安装 fcitx-libs-dev
sudo apt-get install fcitx-libs-dev
(3) 设置环境变量
export PATH="/home/ProgramFiles/Qt5.6.1/5.6/gcc_64/bin":$PATH
其中蓝色部分为安装Qt的位置,,这个根据个人的安装位置情况而定.
git clone https://github.com/fcitx/fcitx-qt5
如果显示没有权限获取,及表明没有秘钥,则可以打开这个网址直接到github上去下载压缩包,再解压即可.
编译 fcitx-qt5
cd fcitx-qt5
cmake .
make
sudo make install
编译成功之后,将编译得到的libfcitxplatforminputcontextplugin.so 文件拷贝到Qt的按装目录下
Tools/QtCreator/bin/plugins/platforminputcontexts
或Tools/QtCreator/lib/Qt/plugins/platforminputcontext
之中,两个目录由安装情况而定,有的会是
第一个路径,有的则是第二个路径,然后再继续将这个文
件放在Qt5.6.1/5.6/gcc_64/plugins/platforminputcontexts之下 最后重启Qt或则重启电脑则可以了.
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!
下载 extra-cmake-modules_1.4.0.orig.tar.xz
链接: https://launchpad.net/ubuntu/+source/extra-cmake-modules/1.4.0-0ubuntu1
解压后进行如下操作:
cd extra-cmake-modules-1.4.0
cmake .
sudo make install
CMake Error at CMakeLists.txt:29 (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.
设置 CMAKE_PREFIX_PATH 环境变量
export CMAKE_PREFIX_PATH="/home/cc/ProgramFiles/Qt5.6.1/5.6/gcc_64/lib/cmake/"
- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- Could NOT find XKBCommon_XKBCommon (missing: XKBCommon_XKBCommon_LIBRARY XKBCommon_XKBCommon_INCLUDE_DIR)
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find XKBCommon (missing: XKBCommon_LIBRARIES XKBCommon) (Required is at least version "0.5.0")
进行安装即可.
sudo apt-get install libxkcommon-dev
编译:
sudo apt-get install bison
./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-x11
make
sudo make install
(1) http://my.oschina.net/lieefu/blog/505363
(2) http://www.gszadc.com/448428224.html
(3) http://www.07net01.com/2016/06/1558676.html