Qt5.3.1 app deployment on Linux troubles
-
Hello everyone. I have some troubles when I deploy my app into Linux-platform. Unless specifically the problem lies in the platforms and sqldivers plugins.
There'r the steps what I did:
I compiled my app in Linux-platform and it's run perfect via QtCreator.
Next I temporary renamed some folder in path to Qt environment to disable this environment.
Next I created a folder e.g. /home/user/bin and replaced my app file, my libs, needed Qt -libs.
Then I added in .bashrc file LD_LIBRARY_PATH variable:
.bashrc:
...
LD_LIBRARY_PATH=/home/usr/bin
export LD_LIBRARY_PATHNext I run ldd ./myapp to check libraries needed. All libs present.
Then I copied platforms and sqldrivers folders to my app folder.
Finally my distribution looks like:
platforms
sqldrivers
myapp
libme.so.1
libQt5Core.so.5
libQt5Gui.so.5
...platforms folder:
libqxcb.so
libqoffscreen.so
libqminimal.so
libqlinuxfb.sosqldrivers folder:
libqsqlmysql.so
libqsqlite.soAnd when I do ./myapp in bash I see:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:
QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
This application failed to start because it could not find or load the Qt platform plugin "xcb"Then I added QT_QPA_PLATFORM_PLUGIN_PATH=/home/user/bin/platforms. Error messages were changed:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:
QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
QFontDatabase: Cannot find font directory /home/usr/Qt/qtbase/lib/fonts - is Qt installed correctly?At the moment I do not know what to do.
-
Hi,
All plugins (except platforms but you already did it right) should go in the plugins subfolder.
Then you should be good to go
-
I have the same troubles ,and when I set the environment variables:LD_LIBRARY_PATH and QT_QPA_PLATFORM_PLUGIN_PATH,then running the app like this:./imagegesture –plugin EvdevTouch ,the error is still exists:
This application failed to start because it could not find or load the Qt platform plugin "xcb".
Reinstalling the application may fix this problem.add the QT_DEBUG_PLUGINS=1 ,i see the error exists because of the libxcb.so'version is incompatibale .
but i have not seen why the parameter "-plugin EdevTouch" has not work but it works in the development enviroment.
My OS is Fedora20 and Qt is 5.3.1
thanks! -
You don't have the same problem. Your target OS doesn't provide a suitable libxcb version.
-
Thanks to all for help.I found the solution.
- We must make visible our libQt5*.so libs and our own libs for runtime. There is 2 ways to do (As I founded):
- use LD_LIBRARY_PATH env variable;
- use chrpath utility (this I used).
I downloaded chrpath utility and change RPATH variable in myapp file.
$ chrpath -r . myapp
This allows runtime to check libraries in same directory when our app located (this Windows-like behavior)
Note. using chrpath -l myapp before changing we can see current RPATH value.
- Copy standart Qt plugins (platforms, sqldrivers etc) to defined directories.
-
in my case it was /usr/lib/kde4/plugins (I defined it using "$ export QT_DEBUG_PLUGINS=1" before running my app). It works but we need root permissions.
I did another way.
I add code to myapp main()-functions and recompile there (and rewrite RPATH var again)
@int main(int argc, char** argv)
{
QStringList paths = QCoreApplication::libraryPaths();
paths.append(".");
paths.append("imageformats");
paths.append("platforms");
paths.append("sqldrivers");
paths.append("fonts");
QCoreApplication::setLibraryPaths(paths);QApplication a(argc, argv);
...
}
@
That means that plugins loader see this subfolders in myapp folder and can find plugins standart libraries in this folders.
- Solution for QFontDatabase error -
3.1) Copy fonts folder from ../qt/lib to .../myappfolder
3.2) Define a QT_QPA_FONTDIR var -
in my case
$ export QT_QPA_FONTDIR=/home/usr/myappfolder/fonts
$ ./myapp
Thats it.
We can do a shell script like this:
@#!/bin/sh
appname=basename $0 | sed s,\.sh$,,
dirname=
dirname $0
tmp="${dirname#?}"if [ "${dirname%$tmp}" != "/" ]; then
dirname=$PWD/$dirname
fi#LD_LIBRARY_PATH=$dirname
#export LD_LIBRARY_PATHexport QT_QPA_FONTDIR=$dirname/fonts
$dirname/$appname "$@"@
Finally myappfolder looks like:
@- fonts folder
- platforms folder
- imageformats folder (also copied from qt-folder/plugins)
- sqldrivers folder
- myapp.sh
- myapp
- libmyown.so.1
- libQt5*.so.5
- ...
@
-
You should Never (™) copy libraries like that, you might end up overwriting your system's own copy of Qt.