QT5.12.0 程序在中標麒麟(neokylin)系統問題處理

前段時間我們的項目想要運行在麒麟系統上,但直接運行不起來,項目以前是支持運行在 ubuntu 18.04 上的,因此遇到一些坑,特此記錄一下。

問題彙總:

窗口不透明

非root用戶下輸入如下命令,並回車

marco -c --replace&

命令解釋:marco 是系統採用的窗口管理器 - c 是打開復合效果

軟件安裝完沒有圖標

之前使用 QT Install FramWork 打包腳本,關於創建桌面圖標是這樣的:

component.addElevatedOperation("CreateDesktopEntry","/usr/share/applications/VPlayer.desktop","Exec=sudo VPlayer");

在麒麟系統上只在 /usr/share/applications 目錄下創建了圖標,桌面上沒有軟件的圖標。ubuntu 也不會在桌面上創建圖標,但是 ubuntu 有 show applications 按鈕。

解決方案:

在打包 installscript.qs 腳本里面新增執行腳本 desktop.sh,desktop.sh 和 VPlayer 可執行文件處於同級目錄。
installscript.qs 如下:

Component.prototype.installationFinished = function()
{
	......
	installer.executeDetached("sh",installer.value("TargetDir")+"/desktop.sh",installer.value("TargetDir"));
}

desktop.sh 腳本如下:

#!/bin/bash
. ~/.config/user-dirs.dirs
cp /usr/share/applications/VPlayer.desktop $SDG_DESKTOP_DIR/VPlayer.desktop
echo $XDG_DESKTOP_DIR >> desktoppath.txt

user-dirs.dirs 文件裏面包含了“桌面”的絕對路徑,然後把它保存下來到 desktoppath.txt。
爲什麼要從這兒獲取路徑,因爲不同的系統語言關於“桌面”的命名是“桌面”或者“Desktop”;
user-dirs.dirs 文件如下:

# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run.
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
# 
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_VIDEOS_DIR="$HOME/Videos"

這個時候當軟件安裝完成後桌面上已經創建出了圖標。但是我們還需要在卸載時移出這個圖標。
installscript.qs 增加命令:

	component.addElevatedOperation("UNDOEXECUTE","sudo","sh","@TargetDir@/deldesktop.sh");	

deldesktop.sh 腳本內容如下:

#!/bin/bash
read path < desktoppath.txt
if [[ "$path" != "" ]];then
rm $path/VPlayer.desktop
fi

雙擊軟件圖標不能啓動

從“Exec=sudo VPlayer”可以看出我們的軟件需要以 root 權限運行,而 root 權限運行時需要輸入密碼的,但雙擊的時候沒法輸入密碼,因此軟件肯定不能啓動了。

解決方案:

我們需要設置無密碼使用 sudo 命令,腳本如下:雙擊執行即可

 #!/bin/bash
wholestring=`who`
name=`echo $wholestring|awk '{print $1}'`
sudo sed -i "/Same thing without a password/a\ $name ALL=(ALL) NOPASSWD: ALL" "/etc/sudoers"   

執行後雙擊圖標即可打開軟件。

運行報錯libc.so.6:version’GLIBC_2.25’-not-found

原因:

./VPlayer: /usr/lib64/libc.so.6: version `GLIBC_2.27’ not found (required by /home/admin/VPlayer/libeffectdisplay.so)

./VPlayer: /usr/lib64/libdbus-1.so.3: no version information available (required by /home/admin/VPlayer/lib/libQt5WebEngineCore.so.5)

libeffectdisplay 這個庫依賴的 libc 版本要求是2.27以上。
libQt5WebEngineCore 這個庫依賴的 libdbus-1.so.3 版本也太低,需要升級(因爲我們的項目基於 QT5.12 構建)。

解決方案:

下載 glibc-2.27 和 dbus-1.13.10 ,或者自己在 linux 下編譯。下載地址(0積分):
glibc-2.27
dbus-1.13.10

1、下載並解壓 glibc-2.27 後,拷貝里面的 libm-2.27.so 到軟件的 lib 目錄下,並生成軟鏈接:

ln -s libm-2.27.so  libm.so.6
ln -s libm-2.27.so  libm.so

2、 下載並解壓 dbus-1.13.10 後,拷貝里面的 libdbus-1.so.3.26.0 到軟件的 lib 目錄下,並生成軟鏈接:

libdbus-1.so.3.26.0  -> libdbus-1.so.3 

再次運行軟件,如果還報錯 libdbus-1.so.3 的問題,則將 libdbus-1.so.3.26.0 拷貝到系統目錄(usr/lib64)下,並生成軟鏈接即可。


csdn地址:http://blog.csdn.net/u012534831
github地址:https://github.com/qht1003077897

如有幫助,請多多點贊支持哦

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章