[TOC]
环境是ubuntu 15.10
ubuntu软件源中下载安装的fctix-libs-qt5
现在没有用,版本太旧了。
自己下载fctix-qt5
的源码来编译即可。
我没有找到fcitx-qt5
的git
仓库地址,只找到了源码包的下载地址。
先下载源码包,并解压。
wget https://download.fcitx-im.org/fcitx-qt5/fcitx-qt5-1.0.5.tar.xz
tar -xJf fcitx-qt5-1.0.5.tar.xz
找到了git仓库地址
git clone http://github.com/fcitx/fcitx-qt5.git
这一步很简单,进入源码目录,然后新建一个build的目录并进入,然后使用cmake
来生成Makefile
cd fcitx-qt5
mkdir build && cd build
cmake ..
这一个步骤产生了几个错误,这和系统环境有关。如果你的没有产生错误,后面就不用看了
错误信息
cmake ..
-- The C compiler identification is GNU 5.2.1
-- The CXX compiler identification is Clang 3.7.0
... ...
-- Detecting CXX compile features - done
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!
See also "/home/o/fcitx/fcitx-qt5/CMakeFiles/CMakeOutput.log".
解决办法
先下载cmake的扩展模块包
wget https://launchpadlibrarian.net/189487929/extra-cmake-modules_1.4.0.orig.tar.xz
tar -xJf extra-cmake-modules_1.4.0.orig.tar.xz
进入其中,然后执行cmake .
来生成Makefile
文件
这一步需要制定两个变量
//The directory containing a CMake configuration file for Qt5Core.
Qt5Core_DIR:PATH=/home/o/program/qt_5.5/qt_5.5.1_x64/5.5/gcc_64/lib/cmake/Qt5Core
//The directory containing a CMake configuration file for Qt5LinguistTools.
Qt5LinguistTools_DIR:PATH=/home/o/program/qt_5.5/qt_5.5.1_x64/5.5/gcc_64/lib/cmake/Qt5LinguistTools
生成了Makefile
之后,直接sudo make install
来安装就可以了。
Qt5
包配置文件的错误报错信息
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.
-- Configuring incomplete, errors occurred!
See also "/home/o/fcitx/fcitx-qt5/build/CMakeFiles/CMakeOutput.log".
这个错误很好解决,设置变量Qt5_DIR
即可
cmake -DQt5_DIR=/home/o/program/qt_5.5/qt_5.5.1_x64/5.5/gcc_64/lib/cmake/Qt5 ..
错误信息
o@o-pc:~/fcitx/fcitx-qt5/build$ cmake -DQt5_DIR=/home/o/program/qt_5.5/qt_5.5.1_x64/5.5/gcc_64/lib/cmake/Qt5 ..
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- Found XKBCommon_XKBCommon: /usr/lib/x86_64-linux-gnu/libxkbcommon.so (found version "0.5.0")
-- Found XKBCommon: /usr/lib/x86_64-linux-gnu/libxkbcommon.so (found suitable version "0.5.0", minimum required is "0.5.0") found components: XKBCommon
-- checking for module 'fcitx-utils'
-- package 'fcitx-utils' not found
CMake Error at /usr/share/cmake-3.2/Modules/FindPkgConfig.cmake:344 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake-3.2/Modules/FindPkgConfig.cmake:506 (_pkg_check_modules_internal)
CMakeLists.txt:32 (pkg_check_modules)
-- Configuring incomplete, errors occurred!
See also "/home/o/fcitx/fcitx-qt5/build/CMakeFiles/CMakeOutput.log".
这个问题的解决如下
先下载libxkbcommon-0.5.0.tar.xz
,然后解压编译
http://xkbcommon.org/download/libxkbcommon-0.5.0.tar.xz
tar -xJf libxkbcommon-0.5.0.tar.xz
这个使用./configure --disable-x11
来生成Makefile。禁用x11
是因为我机器上的x11
版本过高的原因。
编译的时候可能会报错
make
YACC src/xkbcomp/parser.c
./build-aux/ylwrap: 行 176: yacc: 未找到命令
Makefile:1522: recipe for target 'src/xkbcomp/parser.c' failed
make: *** [src/xkbcomp/parser.c] Error 127
需要yacc
的支持。这个工具包含在软件包bison
中。
o@o-pc:~/fcitx/libxkbcommon-0.5.0$ sudo apt-get install bison
然后直接make && make install
安装就是。
这个错误是因为我们没有安装fcitx-libs-dev
的缘故,所以解决的办法就是安装它就是。
错误信息
o@o-pc:~/fcitx/fcitx-qt5/build$ cmake -DQt5_DIR=/home/o/program/qt_5.5/qt_5.5.1_x64/5.5/gcc_64/lib/cmake/Qt5 ..
-- checking for module 'fcitx-utils'
-- package 'fcitx-utils' not found
CMake Error at /usr/share/cmake-3.2/Modules/FindPkgConfig.cmake:344 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake-3.2/Modules/FindPkgConfig.cmake:506 (_pkg_check_modules_internal)
CMakeLists.txt:32 (pkg_check_modules)
-- Configuring incomplete, errors occurred!
解决办法
sudo apt-get install fcitx-libs-dev
经过上面的步骤,生成了Makefile
文件后,接下来的步骤就很简单了,直接make
来编译即可。
make
Scanning dependencies of target FcitxQt5DBusAddons_automoc
[ 4%] Automatic moc for target FcitxQt5DBusAddons
... ... 中间步骤省略
Linking CXX shared module libfcitxplatforminputcontextplugin.so
[100%] Built target fcitxplatforminputcontextplugin
进入构建目录下的platforminputcontext
目录,即可看到生成的libfcitxplatforminputcontextplugin.so
文件
将其拷贝到QtCreator安装目录下的..../QtCreator/bin/plugins/platforminputcontexts
目录下即可。
o@o-pc:~/fcitx/fcitx-qt5/build/platforminputcontext$ ls
CMakeFiles cmake_install.cmake fcitxplatforminputcontextplugin_automoc.cpp libfcitxplatforminputcontextplugin.so Makefile moc_main.cpp moc_qfcitxplatforminputcontext.cpp
cp libfcitxplatforminputcontextplugin.so /home/o/program/qt_5.5/qt_5.5.1_x64/Tools/QtCreator/bin/plugins/platforminputcontexts/