Ubuntu16.04 notepadqq 与 QT

另外方式安装
https://snapcraft.io/install/notepadqq/ubuntu

sudo snap install notepadqq

通过 apt-get 安装的 notepadqq 会出现打不开的情况,图标闪动几下就就就没有然后了
sudo add-apt-repository ppa:notepadqq-team/notepadqq
sudo apt-get update
sudo apt-get install notepadqq

之前也遇到过 Ubuntu12.04 出现过这样子的问题,但是没有解决,后来装了一个sublime text 3 用
当时没想到用命令行的形式去启动这个程序,看看它报什么错误。
今天偶然的机会,Ubuntu16.04 的这个 notepadqq 起不来了,用命令行执行报错,就试了试

出现错误

siasun@ubuntu:~$ notepadqq 
This application failed to start because it could not find or load the Qt platform plugin "xcb".

Reinstalling the application may fix this problem.
Aborted (core dumped)
siasun@ubuntu:~$ 

打开调试信息
export QT_DEBUG_PLUGINS=1
通过观察输出信息看看缺少某些库文件


siasun@ubuntu:~$ export QT_DEBUG_PLUGINS=1
siasun@ubuntu:~$ notepadqq 
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/notepadqq/platforms" ...
This application failed to start because it could not find or load the Qt platform plugin "xcb".

Reinstalling the application may fix this problem.
Aborted (core dumped)
siasun@ubuntu:~$ 

进入到/usr/lib/notepadqq/目录下,发现没有platforms文件夹,ls了一下

siasun@ubuntu:~$ cd /usr/lib/notepadqq/
siasun@ubuntu:/usr/lib/notepadqq$ ls
notepadqq-bin  notepadqq.sh
siasun@ubuntu:/usr/lib/notepadqq$ 

看了看 notepadqq.sh 发现有QT的一些东西,因为本机已经装好了QT5.13.1环境,就试了试
修改 notepadqq.sh 如下
相应添加了QT5.13.1的东西

siasun@ubuntu:/usr/lib/notepadqq$ sudo vim notepadqq.sh 
[sudo] password for siasun: 
siasun@ubuntu:/usr/lib/notepadqq$ cat notepadqq.sh 
#!/bin/sh
SCRIPTPATH="$(dirname "$(readlink -f "$0")")"

if [ `getconf LONG_BIT` = "64" ]
then
    GCC_DIR=gcc_64
else
    GCC_DIR=gcc
fi

OPT_QT513=/opt/Qt5.13.1/5.13.1/$GCC_DIR/lib
OPT_QT510=/opt/Qt/5.10/$GCC_DIR/lib
OPT_QT59=/opt/Qt/5.9/$GCC_DIR/lib
OPT_QT58=/opt/Qt/5.8/$GCC_DIR/lib
OPT_QT57=/opt/Qt/5.7/$GCC_DIR/lib
OPT_QT56=/opt/Qt/5.6/$GCC_DIR/lib
OPT_QT55=/opt/Qt/5.5/$GCC_DIR/lib
OPT_QT54=/opt/Qt/5.4/$GCC_DIR/lib
OPT_QT53=/opt/Qt/5.3/$GCC_DIR/lib
PERSONAL_QT513=~/Qt5.13.1/5.13.1/$GCC_DIR/lib
PERSONAL_QT510=~/Qt/5.10/$GCC_DIR/lib
PERSONAL_QT59=~/Qt/5.9/$GCC_DIR/lib
PERSONAL_QT58=~/Qt/5.8/$GCC_DIR/lib
PERSONAL_QT57=~/Qt/5.7/$GCC_DIR/lib
PERSONAL_QT56=~/Qt/5.6/$GCC_DIR/lib
PERSONAL_QT55=~/Qt/5.5/$GCC_DIR/lib
PERSONAL_QT54=~/Qt/5.4/$GCC_DIR/lib
PERSONAL_QT53=~/Qt/5.3/$GCC_DIR/lib

export LD_LIBRARY_PATH="$OPT_QT513:$PERSONAL_QT513:$OPT_QT510:$PERSONAL_QT510:$OPT_QT59:$PERSONAL_QT59:$OPT_QT58:$PERSONAL_QT58:$OPT_QT57:$PERSONAL_QT57:$OPT_QT56:$PERSONAL_QT56:$OPT_QT55:$PERSONAL_QT55:$OPT_QT54:$PERSONAL_QT54:$OPT_QT53:$PERSONAL_QT53:${LD_LIBRARY_PATH}"

#export LD_LIBRARY_PATH="$OPT_QT510:$PERSONAL_QT510:$OPT_QT59:$PERSONAL_QT59:$OPT_QT58:$PERSONAL_QT58:$OPT_QT57:$PERSONAL_QT57:$OPT_QT56:$PERSONAL_QT56:$OPT_QT55:$PERSONAL_QT55:$OPT_QT54:$PERSONAL_QT54:$OPT_QT53:$PERSONAL_QT53:${LD_LIBRARY_PATH}"

# In Ubuntu Unity, appmenu-qt5 will try to hide our menubar in order to show it as a global bar. 
# This may sometimes fail and leave us with no menu bar. So we'll prevent appmenu-qt5 for doing this.
if [ "$QT_QPA_PLATFORMTHEME" = "appmenu-qt5" ]; then
    export QT_QPA_PLATFORMTHEME=""
fi

# For less common desktop environments, this doesn't get set at all which will cause QT to default to
# using KDE's icon theme settings and cause a lot of missing icon errors.  Most enviornments that don't
# set this preference GTK's settings... so go with that by default.
if [ -z "$XDG_CURRENT_DESKTOP" ]; then
    export XDG_CURRENT_DESKTOP="GNOME"
fi

if [ -f "$SCRIPTPATH"/../lib/notepadqq/notepadqq-bin ]; then
    # Nqq is installed: this script is in bin/
    exec "$SCRIPTPATH"/../lib/notepadqq/notepadqq-bin "$@"
elif [ -f "$SCRIPTPATH"/../lib/notepadqq-bin ]; then
    # Nqq is not installed: this script is in bin/
    exec "$SCRIPTPATH"/../lib/notepadqq-bin "$@"
elif [ -f "$SCRIPTPATH"/../../usr/libexec/notepadqq/notepadqq-bin ]; then
    # Nqq installed via rpm package (Fedora):
    # Script is installed in /usr/libexec/notepadqq folder for comply with FHS and run without changing much
    exec "$SCRIPTPATH"/../../usr/libexec/notepadqq/notepadqq-bin "$@"
else
    # Nqq is installed via deb package:
    # this script is in the same directory as the binary file.
    exec "$SCRIPTPATH"/notepadqq-bin "$@"
fi
siasun@ubuntu:/usr/lib/notepadqq$ 

然后命令行执行 notepadqq 命令,程序起来了

siasun@ubuntu:/usr/lib/notepadqq$ notepadqq 
QFactoryLoader::QFactoryLoader() checking directory path "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/platforms/libqeglfs.so"
Found metadata in lib /opt/Qt5.13.1/5.13.1/gcc_64/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "archreq": 0,
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 331008
}

*********************************************************

Got keys from plugin meta data ("webp")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/notepadqq/imageformats" ...
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqgif.so"
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqicns.so"
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqico.so"
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqjpeg.so"
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqsvg.so"
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqtga.so"
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqtiff.so"
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqwbmp.so"
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/imageformats/libqwebp.so"
QFactoryLoader::QFactoryLoader() checking directory path "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/bearer" ...
QFactoryLoader::QFactoryLoader() looking at "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/bearer/libqconnmanbearer.so"
Found metadata in lib /opt/Qt5.13.1/5.13.1/gcc_64/plugins/bearer/libqconnmanbearer.so, metadata=
{
    "IID": "org.qt-project.Qt.QBearerEngineFactoryInterface",
    "MetaData": {
        "Keys": [
            "connman"
        ]
    },
    "archreq": 0,
    "className": "QConnmanEnginePlugin",
    "debug": false,
    "version": 331008
}


Got keys from plugin meta data ("xcb_glx")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/notepadqq/xcbglintegrations" ...
loaded library "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so"
QFactoryLoader::QFactoryLoader() checking directory path "/opt/Qt5.13.1/5.13.1/gcc_64/plugins/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/notepadqq/accessiblebridge" ...
^C
siasun@ubuntu:/usr/lib/notepadqq$ 
发现这个还有个弊端
只能命令行形式启动,图标启动不起来

// 命令行启动一堆打印信息,看着简直太难受了,重启一个终端就好了,或者 export QT_DEBUG_PLUGINS=0 设置一下就好了

环境变量中设置QT_DEBUG_PLUGINS=1,再执行程序加载插件时,再系统控制台上会输出许多加载插件时的调试信息,可以清楚的看到系统尝试加载了哪些插件,哪些是成功的,哪些没有成功,原因是什么都写的比较清楚。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值