QT5:his application failed to start because it could not find or load the Qt platform plugin "xcb"

前端之家收集整理的这篇文章主要介绍了QT5:his application failed to start because it could not find or load the Qt platform plugin "xcb"前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

问题描述:

当将编译好的QT程序,拷贝到另外一台没有装过QT的设备进行运行时。一般来说,首先会通过ldd命令查找目标程序所依赖的链接文件,将其拷贝到目标设备上。

但是实际情况是,所需要的库一样不少,但是程序就是运行不了。

提示这样的错误

his application Failed to start because it could not find or load the Qt platform plugin "xcb”


解决方法

修改下面的脚本即可:

#!/bin/sh  
  
ExecName=$1 

CUR_PATH=`pwd`

echo "parameters  $# !"

if [ $# -ge 2 ]
then
	dest=$2
else
	echo "Input the dest path,please!"
	exit 1
fi

echo "Package Name:${ExecName} Destination Directory:${dest}"

deplist=$(ldd ${ExecName} | awk  '{if (match($3,"/")){ printf("%s "),$3 } }') 

echo "copy base libraries !"

#clear garbage files
cd ${dest}
rm -rf *
cd ${CUR_PATH}

#begin to copy lib to dest
cp ${deplist} ${dest} 
#copy source file to dest
cp ExecName ${dest}

echo "copy done!"
#/opt/Qt5.6.2/5.6/gcc_64/plugins/platforms
#copy platforms libraries to dest directory
cp /opt/Qt5.6.2/5.6/gcc_64/plugins/platforms/*  ${dest}

cd  ${dest}
echo "Go in ${dest}"
ExecName=libqxcb.so
deplist=$(ldd ${ExecName} | awk  '{if (match($3,$3 } }')  
cp ${deplist} ${dest} 

echo "work done!"


很明显,上面的脚本需要修改的地方,就是将实际的QT安装目录的下的platforms的路径正确填入即可。

运行脚本传入的两个参数分别为 当前目标程序的名字 以及一个即将存放依赖库的目标目录名字


不要忘记的是,以及将QT的lib库的路径加入到LD_LIBRARY_PATH环境变量中


over!

原文链接:https://www.f2er.com/ubuntu/355538.html

猜你在找的Ubuntu相关文章