Solved Unable to deploy Qt app under Linux
-
@kshegunov Oh I see what you were saying. I got caught up on the scripting. ;)
The qt.conf is in the directory containing the executable though. So I still don't understand. It is supposed to be in
bin
with the executable.I read that link just in case I was using qt.conf wrong all these years and I didn't see anything to say it would have a problem if launched from outside the containing directory. I may have missed it though.
When you launch the application like
/path/to/my/app
and your working directory is/home/user
the binary would still get theapplicationDirPath()
as/path/to/my
and that is where it would look for qt.conf. So as far as I can tell you don't need tocd bin
before launching the app. I mean it doesn't hurt to do it, but I don't think it hurts not to do it either. :) -
Your fix_executable.sh script is bad. Here is the output from the build:
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_CORE_LIB -I. -I/usr/local/Qt/include -I/usr/local/Qt/include/QtSql -I/usr/local/Qt/include/QtCore -Itmp-lin64 -I/usr/local/Qt/mkspecs/linux-g++ -o tmp-lin64/main.o src/main.cpp g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_CORE_LIB -I. -I/usr/local/Qt/include -I/usr/local/Qt/include/QtSql -I/usr/local/Qt/include/QtCore -Itmp-lin64 -I/usr/local/Qt/mkspecs/linux-g++ -o tmp-lin64/connectdb.o src/connectdb.cpp src/main.cpp: In function ‘int main(int, char**)’: src/main.cpp:10:16: warning: unused variable ‘dataServer’ [-Wunused-variable] ConnectDB *dataServer = new ConnectDB("QMYSQL", ^~~~~~~~~~ g++ -Wl,-O1 -Wl,-rpath,/usr/local/Qt/lib -o bin/SyncAccountsManager tmp-lin64/main.o tmp-lin64/connectdb.o -L/usr/local/Qt/lib -lQt5Sql -lQt5Core -lpthread /home/mike/tmp/sql-sync-manager-0.12/deb/fix_executable.sh SyncAccountsManager /usr/local/Qt /home/mike/tmp/sql-sync-manager-0.12/bin /home/mike/tmp/sql-sync-manager-0.12 /home/mike/tmp/sql-sync-manager-0.12/deb/fix_executable.sh: line 13: cd: /home/mike/tmp/sql-sync-manager-0.12/deb/files: No such file or directory mkdir: cannot create directory ‘bin’: File exists cp: cannot create regular file '/home/mike/tmp/sql-sync-manager-0.12/deb/files/bin/SyncAccountsManager': No such file or directory chmod: cannot access '/home/mike/tmp/sql-sync-manager-0.12/deb/files/bin/SyncAccountsManager': No such file or directory cp: cannot create regular file '/home/mike/tmp/sql-sync-manager-0.12/deb/files/SyncAccountsManager.sh': No such file or directory chmod: cannot access '/home/mike/tmp/sql-sync-manager-0.12/deb/files/SyncAccountsManager.sh': No such file or directory cp: cannot create regular file '/home/mike/tmp/sql-sync-manager-0.12/deb/files/bin/qt.conf': No such file or directory cp: target '/home/mike/tmp/sql-sync-manager-0.12/deb/files/libs' is not a directory cp: cannot create directory '/home/mike/tmp/sql-sync-manager-0.12/deb/files/libs': No such file or directory make: *** [Makefile:204: bin/SyncAccountsManager] Error 1
The fix is to make sure
deb/files
exists. It doesn't in your source package. Maybe add mkdir to your script or add it to the source dist.Anyway, it's built, I have the same issue with unavailable driver though. But I don't have mysql installed on this machine.
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Unable to connect! ^C
Where would you like me to send the binaries?
-
@ambershark said in Unable to deploy Qt app under Linux:
So as far as I can tell you don't need to cd bin before launching the app.
You don't, that was a dead end long shot on my part.
@mbnoimi , I get only "Unable to connect!" no missing drivers but I haven't copied your binaries for Qt and plugins I'm using my distro's (which happens to be debian) own set.
-
Then yours is working. If you don't get the driver issue your build worked correctly. It can't connect because you don't have the database it is looking for.
-
@ambershark said in Unable to deploy Qt app under Linux:
Then yours is working.
I gathered that. I don't build (and execute) code without taking a peek at what I'm building first. ;)
My bestest of guesses is some problem with the mysql plugin loading. As to why ... I have no idea.Although ... why is
libqsqlmysql.so
inlib/plugins
? I think it only needs to go intolib/plugins/sqldrivers
and there's no reason to have a secondlibQt5Sql.so
inside the plugins folder. These:./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)
are also concerning.
On a related note, if you're deploying on debian why the hell do you want do distribute Qt too??
-
@kshegunov said in Unable to deploy Qt app under Linux:
@ambershark said in Unable to deploy Qt app under Linux:
Then yours is working.
I gathered that. I don't build (and execute) code without taking a peek at what I'm building first. ;)
My bestest of guesses is some problem with the mysql plugin loading. As to why ... I have no idea.Although ... why is
libqsqlmysql.so
inlib/plugins
? I think it only needs to go intolib/plugins/sqldrivers
and there's no reason to have a secondlibQt5Sql.so
inside the plugins folder. These:./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)
are also concerning.
On a related note, if you're deploying on debian why the hell do you want do distribute Qt too??
Yea I originally told him to put them in plugins/sqldrivers and when that didn't work told him to try just in plugins (the old style). Neither changed anything and I'm guessing he just left them in plugins. He should definitely move them back for a real release.
Those messages he gets are my big concern too. I think he has a bad install of something, be it mysql or qt or something on his target system where it isn't working. I was expecting
ldd
to show the problems but for some reason it's not. The problems are still there but ldd isn't shedding light on it. -
@ambershark said in Unable to deploy Qt app under Linux:
I think he has a bad install of something, be it mysql or qt or something on his target system where it isn't working. I
First
ldd
should be run with the proper path (for the qsqlmysql plugin). From the commands he posted he ran it with the default linker locations so it will find the distro's Qt and you he'd get version mismatches. See the lines that follow the command:mbnoimivm@ubuntu:~/files/libs/plugins/sqldrivers$ ldd libqsqlmysql.so ... 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)
-
@kshegunov Yea I warned him about that and told him to run it with LD_LIBRARY_PATH before the ldd. That was like 20 posts ago though. He had similar results that didn't tell me what I needed to know though.
-
Thank you very much @kshegunov & @ambershark
I formatted my PC and the virtual machine I use for testing deployments. I don't use any PPA so I'm using the official packages of GCC and MySQL in Linux Mint 18 x64 xfce repositories.
I get same exact errors I read all your posts twice to be sure everything is fine but I still unable to deploy my app. I pushed the source code to github and the deb file too.
Please guide me how can I fix this issue.
I'm very frustrated because I wasted hours for preparing the deployment even before writing my code. I googled a lot and read all Qt deployment guidance but nothing help me practically.
-
mbnoimivm@ubuntu:~$ /opt/SyncAccountsManager/SyncAccountsManager.sh QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Unable to connect! ^C mbnoimivm@ubuntu:~$
-
If you want to send any files, I can add you to my github project.
@ambershark I added you to my project but @kshegunov I couldn't find you on Github
-
@mbnoimi said in Unable to deploy Qt app under Linux:
I formatted my PC and the virtual machine I use for testing deployments
I tried to run the app on Mint VM and it works fine! so the problem in my Ubuntu VM. I'm using Ubuntu 14.04 while I build the app under LM 18 (built from Ubuntu 16.04) so I've to investigate in Ubuntu libraries.
As I told you before deb package calls the following dependencies
Depends: libmysqlclient20 (>=5.7.11), libstdc++6 (>=4.8.4), libgcc1 (>=1:3.0), libc6 (>=2.14)
Do you think I've to change them for previous Ubuntu versions?
-
Oh yeah... Problem SOLVED at last
The problem occurs because of different versions of
libstdc++6
I fixed it by modifying the dependency from4.8.4
to5.4.0
Ubuntu 14.04 and earlier users need to add the following PPA then Qt 5.7 apps will run smoothly:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update
-
Thanks for sharing your solution.
Cheers. -
@mbnoimi Great news! Sorry I haven't had time for forums in the last few days or I would have continued helping. Sounds like you finally found the culprit. I knew that mysql wasn't loading, but for some reason ldd wasn't showing us why. Glad you finally found it.
And like I said, welcome to the nightmare that is deploying binaries for linux, lol. I hate it!