qt项目无法输入中文,准确来说是无法切换输入法,fcitx-qt5源码在cmake . make 后生成了动态库so文件。把platforminputcontext下cmakelists中的module更改成static,生成了.a静态库。但是在我的项目中代码中调用 lIBS+=位置、Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin),却报错/home/vpn/workplace/core/qtStaticPluginDemo/testStaticDemo/main.cpp:10: error: undefined reference to `qt_static_plugin_QFcitxPlatformInputContextPlugin()'
我的项目是一个打包qt静态编译源码的deb项目,我加载fcit-qt5的静态插件方法是否错了,或者是否是静态库生成错误。或者这种静态项目是否能链接fcitx-qt5的静态库.
Qt5中生成和使用静态库
https://blog.csdn.net/weixin_30432579/article/details/96186967
未定义对“qt_static_plugin_QFcitxPlatformInputContextPlugin()”的引用
你是有头文件没引用?
Filesystem layout:
MyProject
|_ myproject.pro
|_ core
|_ core.cpp
|_ core.h
|_ core.pro
|_ app
|_ main.cpp
|_ app.pro
myproject.pro:
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = core \
app
app.depends = core
core.pro:
TEMPLATE = lib
CONFIG += staticlib
HEADERS = core.h
SOURCES = core.cpp
app.pro:
TEMPLATE = app
SOURCES = main.cpp
LIBS += -L../core -lcore
TARGET = ../app-exe # move executable one dire up
在项目中,我们去查看.pro文件可以发现如下语句:
TARGET = test
TEMPLATE = lib
CONFIG += staticlib
如果想要生成对应debug和release版本的静态库可以使用如下语句去替换TARGET:
win32:CONFIG(debug,debug|release):TARGET = testd
else:win32:CONFIG(release,debug|release):TARGET = test