
|
导读声明:测试的系统环境为ubuntu14.04/ubuntu16.04测试qt的版本有:qt5.6.0/qt5.7.0方法通过测试,qt可以正常输入中文注释。 1.安装fcitx-frontend-q... 声明:测试的系统环境为ubuntu14.04/ubuntu16.04 测试qt的版本有:qt5.6.0/qt5.7.0 方法通过测试,qt可以正常输入中文注释。 1.安装fcitx-frontend-qt5,很重要,很多教程里面没有这个,导致无法正常输入中文注释。笔者在这里纠结了好久,不管这个有没有效,建议安装。 sudo apt-get install fcitx-frontend-qt5 2.安装CMake,由于后面编译文件的时候,对CMake有具体要求,因此在前面的时候直接将cmake升级到3.0以上。 在这里不建议采用源码编译的方式进行,至于为什么,那是因为太费事了。笔者一步一坑走过来的。建议直接更新源升级即可。 sudo apt-get install software-properties-common sudo add-apt-repository ppa:george-edison55/cmake-3.x sudo apt-get update sudo apt-get install cmake 3.安装 fcitx-libs-dev sudo apt-get install fcitx-libs-dev 4.安装extra-cmake-modules_1.4.0,由于在编译fcitx-qt5 源码时会报错。错误提示如下 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 cd extra-cmake-modules-1.4.0 cmake . make sudo make install 注意:注意:注意:重要事情说三遍,在安装extra-cmake-modules_1.4.0如果提示一下错误,那边并没有安装成功。 ~/Downloads/extra-cmake-modules-1.4.0$ cmake . CMake Warning at tests/CMakeLists.txt:28 (find_package): Could not find a package configuration file provided by"Qt5LinguistTools" with any of the following names: Qt5LinguistToolsConfig.cmake qt5linguisttools-config.cmake Add the installation prefix of"Qt5LinguistTools" to CMAKE_PREFIX_PATH or set"Qt5LinguistTools_DIR" to a directory containing one of the above files. If"Qt5LinguistTools" provides a separate development package or SDK, be sure it has been installed. -- Looking for Sphinx Documentation Builder... -- Sphinx Documentation Builder not found - documentation will not be built (see http://sphinx-doc.org/) -- Configuring done -- Generating done -- Build files have been written to: /home/cposture/Downloads/extra-cmake-modules-1.4.0 解决方法如下: 设置 CMAKE_PREFIX_PATH 环境变量 为 qtbase 目录( export CMAKE_PREFIX_PATH="~/Qt5.7.0/5.7/Src/qtbase/" 如果还是不行,则修改为 export CMAKE_PREFIX_PATH="/安装路径/Qt5.7.0/5.7/gcc_64/lib/cmake/" 或export PATH="/安装路径/Qt5.7.0/5.7/gcc_64/bin":$PATH,为了避免麻烦的话,直接在命令行输入这一行就好了。 5.安装xkbcommon 到 http://xkbcommon.org/ 下载最新版的 xkbcommon 解压后, sudo apt-get install bison ./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-x11 make sudo make install 6.下载fcitx-libs 源码并编译安装,具体步骤如下 首先确定你的Qt的安装目录,我这里是~/Qt5.7.0/,你的或者可能在/home/<用户名>/Qt5.7.0/用户名> export PATH="/5.7/gcc_64/bin":$PATH 下载fcitx-libs源码 git clone https://github.com/fcitx/fcitx-qt5 如果这里提示木有git,下载安装一个即可。 sudo apt-get install git 下载源码解压后按照以下步骤编译 cd fcitx-qt5 cmake .(这里是有个点的,一定要记住哦) make sudo make install 7.将编译好的libfcitxplatforminputcontextplugin.so文件分别拷贝到Tools/QtCreator/lib/Qt/plugins/platforminputcontexts。和 Qt5.7.0/5.7/GCC_64/plugins/platforminputcontexts并且将两个文件的权限提上去。 chmod +x 文件路劲/文件名 笔者这两个文件中,这个Qt5.7.0/5.7/GCC_64/plugins/platforminputcontexts文件下的文件是带锁的,此时需要解锁,然后进行替换。 sudo chmod 777 /文件路径/文件名 8.配置系统环境 echo 'export XMODIFIERS=@im=fcitx' >>.bashrc echo 'export QT_IM_MODULE=fcitx' >>.bashrc 最好确认下是否配置好,笔者就碰到过没有配置成功的情况。 sudo gedit .bashrc 9.关机重启。请记住,一定要关机重启,避免不能输入中文。 10.建议大家可以下载我编译的文件,然后按照步骤1、步骤7、8、9尝试一下,笔者并没有尝试,但从理论上来说是可以拷贝并生效的。 下载地址 备注:笔者默认大家都是装了搜狗输入法的,如果没装,请参照搜狗官网即可。在这里就不加赘述了。 |
温馨提示:喜欢本站的话,请收藏一下本站!