原先在Debian
系下的Qtcreator
无法输入中文时,可以直接在软件源下载fcitx-libs-qt
和fcitx-libs-qt5
,然后复制到相应的目录下即可实现输入中文,但是现在Qtcreator
已经发布了很多新版本了,软件园的fcitx
已经太旧,下载下来也没有什么用了。所以得自己编译最新的的版本才能让Qtcreator
支持中文。
我的系统是Deepin 15.11
,Qt 5.12.3
, QtCreator 4.9(base on 5.12.2)
。
fcitx-libs-dev
sudo apt-get install fcitx-libs-dev
不装这个会出现'fcitx-utils' not found
错误
qmake
环境这里需要找到你自己的安装目录
export PATH="~/Qt5.12.3/5.12.3/gcc_64/bin":$PATH
fcitx-qt5
源码并解压wget https://download.fcitx-im.org/fcitx-qt5/fcitx-qt5-1.0.5.tar.xz
tar -xJf fcitx-qt5-1.0.5.tar.xz
这里如果一次没出问题,那运气不错,直接下一步。
cd fcitx-qt5-1.2.3
cmake .
make
sudo make install
so
文件Qtcreator
能够输入中文,将编译好的so
文件放在以下目录~/Qt5.12.3/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts
Qtcreator
开发的程序能够输入中文,要将so
放在以下目录~Qt5.12.3/5.12.3/gcc_64/plugins/platforminputcontexts
编译fcitx-qt5
会遇到一箩筐的问题,这里记录下我遇到的问题
ECM
包配置文件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 "~/fcitx/fcitx-qt5/CMakeFiles/CMakeOutput.log".
这里的提示说明,需要1.4.0
版本的ECM
配置文件,所以到下面的网址下载并安装这个东西即可。但是安装这个东西有可能也安装不成,还需要下一步来解决
wget https://launchpad.net/ubuntu/+source/extra-cmake-modules/1.4.0-0ubuntu1
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
这里的解决方案比较简单,设置CMAKE_PREFIX_PATH
的值为Qt
自带的cmake
目录即可
export CMAKE_PREFIX_PATH="~/Qt5.12.3/5.12.3/gcc_64/lib/cmake/"
这里设置完了就可以返回去重新编译安装 extra-cmake-modules-1.4.0
了
Qt5
所提供的配置文件-- Performing Test SUPPORT_CXX11
-- Performing Test SUPPORT_CXX11 - Success
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!
这个问题的解决方法同1.1的方法一样
xkbcommon
包-- 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 bison
./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-x11
make
sudo make install
安装bison
的原因是需要用到YACC
命令,然后因为系统的X11
版本较高,所以得得禁用掉。我在桌面环境崩溃之后,在命令行中用旧版本的xkbcommon
替换/usr/lib/x86_64-linux-gnu
目录下的新装上的,然后在修改头文件。就可以恢复了,但是这个方法太粗暴了。