Solved Unable to deploy Qt app under Linux
-
@kshegunov said in Unstripped binary or object!:
QMAKE_RPATHDIR =
QMAKE_RPATHLINKDIR = # Possibly not neededStill get same error message:
E: sync-accounts-manager: binary-or-shlib-defines-rpath opt/sync-accounts-manager/SyncAccountsManager /home/mbnoimi/.Qt/5.7/gcc_64/lib
-
I pushed my init project to github so because of this error I'm unable to connect to database:
mbnoimivm@ubuntu:~$ /opt/sync-accounts-manager/SyncAccountsManager.sh QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Unable to connect! ^C mbnoimivm@ubuntu:~$ ldd /opt/sync-accounts-manager/SyncAccountsManager /opt/sync-accounts-manager/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by /opt/sync-accounts-manager/SyncAccountsManager) /opt/sync-accounts-manager/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by /opt/sync-accounts-manager/SyncAccountsManager) /opt/sync-accounts-manager/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: no version information available (required by /opt/sync-accounts-manager/SyncAccountsManager) linux-vdso.so.1 => (0x00007ffd5594c000) libQt5Sql.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5 (0x00007f86d6806000) libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f86d6160000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f86d5e5b000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f86d5c45000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f86d5880000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f86d5661000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f86d5448000) libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007f86d5041000) libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007f86d4cc7000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f86d4ac3000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f86d47bb000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f86d45b2000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f86d42ac000) /lib64/ld-linux-x86-64.so.2 (0x000055adc312e000) libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007f86d2a3e000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f86d2800000) mbnoimivm@ubuntu:~$
-
@mbnoimi
Try runningchrpath -d
on your binary (and/or Qt) to remove the rpath. -
@mbnoimi Do you have mysql as a plugin in Qt? If so you need to make sure you have the plugins set up on your machine properly.
On your development machine they will work properly but when you distribute they may not.
Usually I distribute then in the lib directory I use and then plugins, so something like this:
myapp/ bin/ myapp (actual binary) qt.conf libs/ libmylib.so libQt5Core.so.5 plugins/ platforms/ libqxcb.so (linux) sqldrivers/ libsqlmysql.so myapp (shell script to launch with a custom LD path)
Inside the qt.conf file you need:
[Paths] Plugins = ../libs/plugins
Then I use a shell script to start my app:
#!/bin/sh dir="$(dirname `readlink -f $0`)" LD_LIBRARY_PATH="$dir/libs:$LD_LIBRARY_PATH" QT_QPA_FONTDIR="$dir/fonts" export LD_LIBRARY_PATH QT_QPA_FONTDIR exec $dir/bin/myapp "$\@"
Finally make sure you use
chrpath
to strip RPATH info out of your binaries (apps and libs) as suggested by @kshegunov . If they have hard coded paths as built on your system and those paths do not exist on your target system they will not work. If the path is gone it will use theLD_LIBRARY_PATH
.Make sure you have the libraries you wanted to distribute in
libs
and all others (i.e. Qt) in LD path areas on your system and you should be good to go.That was a long answer to saying basically your app can't find the mysql Qt plugin. ;) Hopefully it helps though, I've gone through a lot of headache getting binary apps distributed for Linux in the past.
-
@ambershark I did as you advice but I'm still get same errors!
Files tree:
. ├── bin │ ├── qt.conf │ └── SyncAccountsManager ├── libs │ ├── libicudata.so.56 -> libicudata.so.56.1 │ ├── libicudata.so.56.1 │ ├── libicui18n.so.56 -> libicui18n.so.56.1 │ ├── libicui18n.so.56.1 │ ├── libicuuc.so.56 -> libicuuc.so.56.1 │ ├── libicuuc.so.56.1 │ ├── libqgsttools_p.prl │ ├── libqgsttools_p.so -> libqgsttools_p.so.1.0.0 │ ├── libqgsttools_p.so.1 -> libqgsttools_p.so.1.0.0 │ ├── libqgsttools_p.so.1.0 -> libqgsttools_p.so.1.0.0 │ ├── libqgsttools_p.so.1.0.0 │ ├── libQt5Core.so -> libQt5Core.so.5.7.0 │ ├── libQt5Core.so.5 -> libQt5Core.so.5.7.0 │ ├── libQt5Core.so.5.7 -> libQt5Core.so.5.7.0 │ ├── libQt5Core.so.5.7.0 │ ├── libQt5Gui.la │ ├── libQt5Gui.prl │ ├── libQt5Gui.so -> libQt5Gui.so.5.7.0 │ ├── libQt5Gui.so.5 -> libQt5Gui.so.5.7.0 │ ├── libQt5Gui.so.5.7 -> libQt5Gui.so.5.7.0 │ ├── libQt5Gui.so.5.7.0 │ ├── libQt5Sql.la │ ├── libQt5Sql.prl │ ├── libQt5Sql.so -> libQt5Sql.so.5.7.0 │ ├── libQt5Sql.so.5 -> libQt5Sql.so.5.7.0 │ ├── libQt5Sql.so.5.7 -> libQt5Sql.so.5.7.0 │ ├── libQt5Sql.so.5.7.0 │ └── plugins │ ├── platforms │ │ ├── libqeglfs.so │ │ ├── libqlinuxfb.so │ │ ├── libqminimalegl.so │ │ ├── libqminimal.so │ │ ├── libqoffscreen.so │ │ └── libqxcb.so │ └── sqldrivers │ ├── libqsqlite.so │ ├── libqsqlmysql.so │ └── libqsqlpsql.so └── SyncAccountsManager.sh
QT += core sql QT -= gui TARGET = SyncAccountsManager CONFIG += c++11 CONFIG += release CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += src/main.cpp \ src/connectdb.cpp HEADERS += \ src/connectdb.h DESTDIR = bin win32 { MOC_DIR = tmp-win32 UI_DIR = tmp-win32 UI_HEADERS_DIR = tmp-win32 UI_SOURCES_DIR = tmp-win32 OBJECTS_DIR = tmp-win32 RCC_DIR = tmp-win32 } linux { MOC_DIR = tmp-lin64 UI_DIR = tmp-lin64 UI_HEADERS_DIR = tmp-lin64 UI_SOURCES_DIR = tmp-lin64 OBJECTS_DIR = tmp-lin64 RCC_DIR = tmp-lin64 # QMAKE_POST_LINK = strip $${PWD}/$${DESTDIR}/$${TARGET} # QMAKE_RPATHDIR = # QMAKE_RPATHLINKDIR = # Possibly not needed QMAKE_POST_LINK = $${PWD}/src/fix_executable.sh $${TARGET} $$(QTDIR) $${PWD}/$${DESTDIR} $${PWD} }
fix_executable.sh
#!/bin/sh appname="$1" qt="$2" binpath="$3" project_path="$4" distro=$project_path/deb/files #### Clean the app strip $binpath/$appname chrpath -d $binpath/$appname #### Create files tree #### cd $distro rm -fr $distro/* mkdir bin mkdir -p libs/plugins cp -fr $binpath $distro chmod +x $distro/bin/$appname.sh mv -f $distro/bin/$appname.sh $distro cp -fr $qt/lib/* $distro/libs cp -fr $qt/plugins $distro/libs
ldd result on the deployed machine:
mbnoimivm@ubuntu:~/files$ ./SyncAccountsManager.sh QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Unable to connect! ^C mbnoimivm@ubuntu:~/files$ ldd bin/SyncAccountsManager bin/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by bin/SyncAccountsManager) bin/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by bin/SyncAccountsManager) bin/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: no version information available (required by bin/SyncAccountsManager) linux-vdso.so.1 => (0x00007ffe1044f000) libQt5Sql.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5 (0x00007f62ea9c7000) libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f62ea321000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f62ea01c000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f62e9e06000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f62e9a41000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f62e9822000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f62e9609000) libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007f62e9202000) libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007f62e8e88000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f62e8c84000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f62e897c000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f62e8773000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f62e846d000) /lib64/ld-linux-x86-64.so.2 (0x00005653e78dc000) libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007f62e6bff000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f62e69c1000) mbnoimivm@ubuntu:~/files$
-
ldd result on the deployed machine:
mbnoimivm@ubuntu:~/files$ ./SyncAccountsManager.sh QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Unable to connect! ^C mbnoimivm@ubuntu:~/files$ ldd bin/SyncAccountsManager bin/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by bin/SyncAccountsManager) bin/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by bin/SyncAccountsManager) bin/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: no version information available (required by bin/SyncAccountsManager) linux-vdso.so.1 => (0x00007ffe1044f000) libQt5Sql.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5 (0x00007f62ea9c7000) libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f62ea321000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f62ea01c000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f62e9e06000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f62e9a41000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f62e9822000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f62e9609000) libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007f62e9202000) libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007f62e8e88000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f62e8c84000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f62e897c000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f62e8773000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f62e846d000) /lib64/ld-linux-x86-64.so.2 (0x00005653e78dc000) libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007f62e6bff000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f62e69c1000) mbnoimivm@ubuntu:~/files$
Ok so it looks like it is picking up your system Qt and not the one you want it to use. That is controlled with LD_LIBRARY_PATH.. In your synaccountsmanager.sh it may be working but since you used
ldd bin/SyncAccountsManager
it didn't use the ld library path properly so it could be right but from what I'm looking at it's definitely not.So run ldd like this:
$ cd yourapp/bin $ LD_LIBRARY_PATH="../libs" ldd ./SyncAccountsManager
That should give us the output we want. Also make sure your
.sh
start script sets your LD_LIBRARY_PATH just like that. You could try running it straight on the command line like that and see if it works. If not the ldd output will be useful at least.One of the things that is most concerning is this line:
bin/SyncAccountsManager: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: no version information available (required by bin/SyncAccountsManager)
Also I don't see libQt5Sql.so.5 in your libs directory. I'm sure you need that if you're using SQL. ;)
-
@ambershark said in Unable to deploy Qt app under Linux:
Ok so it looks like it is picking up your system Qt and not the one you want it to use. That is controlled with LD_LIBRARY_PATH.. In your synaccountsmanager.sh it may be working but since you used ldd bin/SyncAccountsManager it didn't use the ld library path properly so it could be right but from what I'm looking at it's definitely not.
The content of SyncAccountsManager.sh
#!/bin/sh dir="$(dirname `readlink -f $0`)" LD_LIBRARY_PATH="$dir/libs:$LD_LIBRARY_PATH" QT_QPA_FONTDIR="$dir/fonts" export LD_LIBRARY_PATH QT_QPA_FONTDIR exec $dir/bin/SyncAccountsManagermyapp "$\@"
So run ldd like this:
$ cd yourapp/bin
$ LD_LIBRARY_PATH="../libs" ldd ./SyncAccountsManagerThat should give us the output we want. Also make sure your .sh start script sets your LD_LIBRARY_PATH just like that. You could try running it straight on the command line like that and see if it works.
The result of ldd:
mbnoimivm@ubuntu:~$ cd files/bin mbnoimivm@ubuntu:~/files/bin$ LD_LIBRARY_PATH="../libs" ldd ./SyncAccountsManager linux-vdso.so.1 => (0x00007ffe11f17000) libQt5Sql.so.5 => ../libs/libQt5Sql.so.5 (0x00007f73059e7000) libQt5Core.so.5 => ../libs/libQt5Core.so.5 (0x00007f73052cc000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7304fbf000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7304da9000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f73049e4000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f73047c5000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f73044bf000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f73042a6000) libicui18n.so.56 => ../libs/libicui18n.so.56 (0x00007f7303e0b000) libicuuc.so.56 => ../libs/libicuuc.so.56 (0x00007f7303a53000) libicudata.so.56 => ../libs/libicudata.so.56 (0x00007f7302070000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7301e6b000) libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f7301c69000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7301a61000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f7301758000) /lib64/ld-linux-x86-64.so.2 (0x000055c051da4000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f730151a000) mbnoimivm@ubuntu:~/files/bin$
Also I don't see libQt5Sql.so.5 in your libs directory. I'm sure you need that if you're using SQL. ;)
No, it's in my files tree see above please.
-
I tried the following but I got same result:
mbnoimivm@ubuntu:~/files/bin$ LD_LIBRARY_PATH="../libs" ./SyncAccountsManager QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Unable to connect! ^C mbnoimivm@ubuntu:~/files/bin$
-
Sure is in that list, I must have missed it.. Ok so let's try moving those sqldrivers... Sometimes I have issues with where Qt looks for plugins.
Instead of
plugins/sqldrivers
try making a copy of those libsql.so files inplugins/
. Then see if that works. I'll try to think of anything else that might be going on while you try that. -
Ok then after that lets see if this is a mysql problem and not a Qt one. Run
ldd libqsqlmysql.so
and post that output. It may be looking for a mysql library that was upgraded and no longer on your system.Oh and it shouldn't affect the driver only class availability but make sure you have
QT += sql
in your pro file. Just in case it does affect it... But I doubt it will. -
@ambershark said in Unable to deploy Qt app under Linux:
Instead of plugins/sqldrivers try making a copy of those libsql.so files in plugins/. Then see if that works. I'll try to think of anything else that might be going on while you try that.
Same error :(
mbnoimivm@ubuntu:~$ files/SyncAccountsManager.sh QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Unable to connect! ^C mbnoimivm@ubuntu:~$ tree -R files/ files/ ├── bin │ ├── qt.conf │ └── SyncAccountsManager ├── libs │ ├── libicudata.so.56 │ ├── libicudata.so.56.1 │ ├── libicui18n.so.56 │ ├── libicui18n.so.56.1 │ ├── libicuuc.so.56 │ ├── libicuuc.so.56.1 │ ├── libqgsttools_p.prl │ ├── libqgsttools_p.so │ ├── libqgsttools_p.so.1 │ ├── libqgsttools_p.so.1.0 │ ├── libqgsttools_p.so.1.0.0 │ ├── libQt5Core.so │ ├── libQt5Core.so.5 │ ├── libQt5Core.so.5.7 │ ├── libQt5Core.so.5.7.0 │ ├── libQt5Sql.la │ ├── libQt5Sql.prl │ ├── libQt5Sql.so │ ├── libQt5Sql.so.5 │ ├── libQt5Sql.so.5.7 │ ├── libQt5Sql.so.5.7.0 │ └── plugins │ ├── libqsqlite.so │ ├── libqsqlmysql.so │ ├── libqsqlpsql.so │ ├── libQt5Sql.la │ ├── libQt5Sql.prl │ ├── libQt5Sql.so │ ├── libQt5Sql.so.5 │ ├── libQt5Sql.so.5.7 │ ├── libQt5Sql.so.5.7.0 │ ├── platforms │ │ ├── libqeglfs.so │ │ ├── libqlinuxfb.so │ │ ├── libqminimalegl.so │ │ ├── libqminimal.so │ │ ├── libqoffscreen.so │ │ └── libqxcb.so │ └── sqldrivers │ ├── libqsqlite.so │ ├── libqsqlmysql.so │ └── libqsqlpsql.so └── SyncAccountsManager.sh 5 directories, 42 files mbnoimivm@ubuntu:~$
-
@ambershark said in Unable to deploy Qt app under Linux:
Ok then after that lets see if this is a mysql problem and not a Qt one. Run ldd libqsqlmysql.so and post that output. It may be looking for a mysql library that was upgraded and no longer on your system.
mbnoimivm@ubuntu:~/files/libs/plugins/sqldrivers$ ldd libqsqlmysql.so ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: no version information available (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: no version information available (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by ./libqsqlmysql.so) linux-vdso.so.1 => (0x00007fff87591000) libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007faa39173000) libQt5Sql.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5 (0x00007faa38f34000) libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007faa3888d000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007faa38589000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa381c4000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faa37fbf000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007faa37da1000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faa37a9b000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007faa37884000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007faa3766b000) libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007faa37264000) libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007faa36eea000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007faa36be2000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007faa369da000) /lib64/ld-linux-x86-64.so.2 (0x000055741e96f000) libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007faa3516c000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007faa34f2e000) mbnoimivm@ubuntu:~/files/libs/plugins/sqldrivers$
-
I tried to apply
strip
but unfortunately it didn't fix the problemmbnoimivm@ubuntu:~/files/libs/plugins/sqldrivers$ strip libqsqlmysql.so mbnoimivm@ubuntu:~/files/libs/plugins/sqldrivers$ ldd libqsqlmysql.so ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: no version information available (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: no version information available (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by ./libqsqlmysql.so) linux-vdso.so.1 => (0x00007ffd21f90000) libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007fa3fe87c000) libQt5Sql.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5 (0x00007fa3fe63d000) libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007fa3fdf96000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa3fdc92000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa3fd8cd000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa3fd6c8000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa3fd4aa000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa3fd1a4000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa3fcf8d000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fa3fcd74000) libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007fa3fc96d000) libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007fa3fc5f3000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fa3fc2eb000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa3fc0e3000) /lib64/ld-linux-x86-64.so.2 (0x0000562224202000) libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007fa3fa875000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fa3fa637000) mbnoimivm@ubuntu:~/files/libs/plugins/sqldrivers$
-
IMPORTANT:
Although this distro works fine on the original PC but I get this error byldd
:mbnoimi@mbnoimi-laptop ~/HPC/SyncAccountsManager/deb/files/libs/plugins/sqldrivers $ ldd libqsqlmysql.so ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: version `Qt_5_PRIVATE_API' not found (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5: version `Qt_5' not found (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.7' not found (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5_PRIVATE_API' not found (required by ./libqsqlmysql.so) ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5' not found (required by ./libqsqlmysql.so) linux-vdso.so.1 => (0x00007ffe9f9fd000) libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007f8bd5f9b000) libQt5Sql.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5 (0x00007f8bd5f59000) libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f8bd5a82000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8bd5700000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8bd5337000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f8bd511c000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8bd4f18000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8bd4cfb000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8bd49f1000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8bd47db000) libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55 (0x00007f8bd4379000) libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007f8bd3fe4000) libpcre16.so.3 => /usr/lib/x86_64-linux-gnu/libpcre16.so.3 (0x00007f8bd3d7e000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f8bd3a6d000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8bd3864000) /lib64/ld-linux-x86-64.so.2 (0x0000563fd9f32000) libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007f8bd1dad000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f8bd1b3c000) mbnoimi@mbnoimi-laptop ~/HPC/SyncAccountsManager/deb/files/libs/plugins/sqldrivers $
-
@mbnoimi
How did any of this have anything to do withstrip
or.deb
packages?Here: http://doc.qt.io/qt-5/linux-deployment.html#creating-the-application-package
You haven't followed the required directory structure and you're executing the application from a directory different fromqt.conf
's location.Warning: On Linux, this function will try to get the path from the /proc file system. If that fails, it assumes that argv[0] contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.
From here. I'd start by fixing up the shell script. You don't escape the file name of the script but instead quote the whole commands, this doesn't make much sense. Try something like this:
#!/bin/sh # Don't spawn children shells unnecessarily by using ` dir=$(dirname $(readlink -f "$0")) # The following might happen to be pretty important cd $dir'/bin' # Execute from the current shell's context and no need to export if you don't spawn a new shell process app=$dir'/bin/SyncAccountsManagermyapp' LD_LIBRARY_PATH=$dir'/libs:'$LD_LIBRARY_PATH QT_QPA_FONTDIR=$dir'/fonts' $app "$@"
-
@kshegunov I did exactly as you suggested although I didn't notice any problem in the old
appname.sh
file. Any way your suggestion gave me exactly same error!
May you please take a look into https://github.com/mbnoimi/sql-sync-manager/releases/tag/0.12 -
@kshegunov said in Unable to deploy Qt app under Linux:
@mbnoimi
How did any of this have anything to do withstrip
or.deb
packages?Here: http://doc.qt.io/qt-5/linux-deployment.html#creating-the-application-package
You haven't followed the required directory structure and you're executing the application from a directory different fromqt.conf
's location.Warning: On Linux, this function will try to get the path from the /proc file system. If that fails, it assumes that argv[0] contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.
From here. I'd start by fixing up the shell script. You don't escape the file name of the script but instead quote the whole commands, this doesn't make much sense. Try something like this:
#!/bin/sh # Don't spawn children shells unnecessarily by using ` dir=$(dirname $(readlink -f "$0")) # The following might happen to be pretty important cd $dir'/bin' # Execute from the current shell's context and no need to export if you don't spawn a new shell process app=$dir'/bin/SyncAccountsManagermyapp' LD_LIBRARY_PATH=$dir'/libs:'$LD_LIBRARY_PATH QT_QPA_FONTDIR=$dir'/fonts' $app "$@"
His problem is definitely deeper than the start script. As we've had him do it direct on the command line with the same results.
Some of the other comments on the start script you made I don't understand. For instance the only difference in $() and backtick in a bash script is looks. Under the covers they both do the same thing. I go back and forth on which I use, they act the exact same though and neither starts an extra shell compared to the first. The newer syntax is $() because they look better but backtick was not deprecated or anything.
The other thing is you mention has to do with escaping. If
dir = /a path with spaces/mydir
then the script would fail. The original script suffers from the same non-escaping though. Just not sure what your comment meant. The "$@" is a bug though, the \ shouldn't be there.Anyway back on to the problem at hand. I'm betting you might have a bad mysql lib. I would remove Qt from the equation and test a binary linked against mysql directly. See if it works. If it does I may have another idea for you, if not then fix your MySQL and you should be all set. ;)
-
@ambershark said in Unable to deploy Qt app under Linux:
Anyway back on to the problem at hand. I'm betting you might have a bad mysql lib. I would remove Qt from the equation and test a binary linked against mysql directly. See if it works. If it does I may have another idea for you, if not then fix your MySQL and you should be all set. ;)
I built recent MySQL library against Qt (from Oracle PPA) for that I made my distro using *.deb becuase it asks the user for the following depends (Debreate project file SyncAccountsManager.dbp)
Depends: libmysqlclient20 (>=5.7.11), libstdc++6 (>=4.8.4), libgcc1 (>=1:3.0), libc6 (>=2.14)
I'm not sure if this affect on the distro. Another thing I'm using recent GCC because I use some code written in recent C++ version:
mbnoimi@mbnoimi-laptop ~ $ gcc --version gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. mbnoimi@mbnoimi-laptop ~ $
Using the above
gcc
I built Qt MySQL Plugin but on my machine everything fine and I'm able to connect to MySQL without any problem. -
Guys, may I ask you for a tiny test:
Could you please build this release then upload the binaries for me?
-
Yea that sounds like your problem then. You used a different mysql and didn't distribute your custom one to the target system. And you should NOT do this as that would violate the license of mysql.
I'm betting Qt is looking for a mysql version that isn't there or isn't working properly. Hence the "no driver" error message.
Welcome to the wonderful world of making linux binaries. It is painful. It takes a lot of time and effort to solve all these problems. It sounds like you should have a good jumping off point to figure out where you went wrong with mysql though.
You can try making sure the mysql stuff on the target machine is the same as on your machine. Use
ldd
liberally in trying to find what binaries are failing to load. And finally you can try something likestrace
to see what operations are running when it fails. OH and don'tstrip
your binaries before distribution and try running the application throughgdb
. The call stack may give you insight as to why the mysql on the target machine is not good enough.One last idea, make sure you linked against the same bit size as the target machine. I.e. if you linked 64-bit and the target is 32-bit it would not work and have driver issues.