Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to deploy Qt app under Linux
Forum Updated to NodeBB v4.3 + New Features

Unable to deploy Qt app under Linux

Scheduled Pinned Locked Moved Solved General and Desktop
43 Posts 3 Posters 14.6k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M mbnoimi

    @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 ./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.

    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.

    M Offline
    M Offline
    mbnoimi
    wrote on last edited by
    #15

    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$
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #16

      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 in plugins/. Then see if that works. I'll try to think of anything else that might be going on while you try that.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      M 1 Reply Last reply
      0
      • A Offline
        A Offline
        ambershark
        wrote on last edited by ambershark
        #17

        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.

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        M 1 Reply Last reply
        0
        • A ambershark

          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 in plugins/. Then see if that works. I'll try to think of anything else that might be going on while you try that.

          M Offline
          M Offline
          mbnoimi
          wrote on last edited by
          #18

          @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:~$
          
          kshegunovK 1 Reply Last reply
          0
          • A ambershark

            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.

            M Offline
            M Offline
            mbnoimi
            wrote on last edited by
            #19

            @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$
            
            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbnoimi
              wrote on last edited by
              #20

              I tried to apply strip but unfortunately it didn't fix the problem

              mbnoimivm@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$
              
              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbnoimi
                wrote on last edited by mbnoimi
                #21

                IMPORTANT:
                Although this distro works fine on the original PC but I get this error by ldd:

                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 $ 
                
                
                1 Reply Last reply
                0
                • M mbnoimi

                  @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:~$
                  
                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #22

                  @mbnoimi
                  How did any of this have anything to do with strip 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 from qt.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 "$@"
                  

                  Read and abide by the Qt Code of Conduct

                  M A 2 Replies Last reply
                  0
                  • kshegunovK kshegunov

                    @mbnoimi
                    How did any of this have anything to do with strip 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 from qt.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 "$@"
                    
                    M Offline
                    M Offline
                    mbnoimi
                    wrote on last edited by
                    #23

                    @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

                    1 Reply Last reply
                    0
                    • kshegunovK kshegunov

                      @mbnoimi
                      How did any of this have anything to do with strip 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 from qt.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 "$@"
                      
                      A Offline
                      A Offline
                      ambershark
                      wrote on last edited by
                      #24

                      @kshegunov said in Unable to deploy Qt app under Linux:

                      @mbnoimi
                      How did any of this have anything to do with strip 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 from qt.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. ;)

                      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                      M kshegunovK 2 Replies Last reply
                      1
                      • A ambershark

                        @kshegunov said in Unable to deploy Qt app under Linux:

                        @mbnoimi
                        How did any of this have anything to do with strip 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 from qt.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. ;)

                        M Offline
                        M Offline
                        mbnoimi
                        wrote on last edited by
                        #25

                        @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.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mbnoimi
                          wrote on last edited by
                          #26

                          Guys, may I ask you for a tiny test:

                          Could you please build this release then upload the binaries for me?

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            ambershark
                            wrote on last edited by
                            #27

                            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 like strace to see what operations are running when it fails. OH and don't strip your binaries before distribution and try running the application through gdb. 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.

                            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                            1 Reply Last reply
                            0
                            • A ambershark

                              @kshegunov said in Unable to deploy Qt app under Linux:

                              @mbnoimi
                              How did any of this have anything to do with strip 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 from qt.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. ;)

                              kshegunovK Offline
                              kshegunovK Offline
                              kshegunov
                              Moderators
                              wrote on last edited by
                              #28

                              @ambershark said in Unable to deploy Qt app under Linux:

                              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.

                              You're most certainly correct. One should take my scripting "skills" with a grain of salt. What I still insist on, however, is that the application is executed from a folder that is different from the one that qt.conf resides in. This can (and possibly does) break the way the plugins are resolved (i.e. the .so locations). If you follow the documentation page on deployment you'd see that the example puts everything (app, conf file) in the root folder and the plugin directory is under that too. That's why I also referenced the warning in the docs.

                              Read and abide by the Qt Code of Conduct

                              1 Reply Last reply
                              1
                              • A Offline
                                A Offline
                                ambershark
                                wrote on last edited by ambershark
                                #29

                                @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 the applicationDirPath() 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 to cd 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. :)

                                My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                                kshegunovK 1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  ambershark
                                  wrote on last edited by
                                  #30

                                  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?

                                  My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                                  1 Reply Last reply
                                  0
                                  • A ambershark

                                    @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 the applicationDirPath() 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 to cd 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. :)

                                    kshegunovK Offline
                                    kshegunovK Offline
                                    kshegunov
                                    Moderators
                                    wrote on last edited by kshegunov
                                    #31

                                    @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.

                                    Read and abide by the Qt Code of Conduct

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      ambershark
                                      wrote on last edited by
                                      #32

                                      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.

                                      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                                      kshegunovK 1 Reply Last reply
                                      0
                                      • A ambershark

                                        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.

                                        kshegunovK Offline
                                        kshegunovK Offline
                                        kshegunov
                                        Moderators
                                        wrote on last edited by kshegunov
                                        #33

                                        @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 in lib/plugins? I think it only needs to go into lib/plugins/sqldrivers and there's no reason to have a second libQt5Sql.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??

                                        Read and abide by the Qt Code of Conduct

                                        A 1 Reply Last reply
                                        1
                                        • kshegunovK kshegunov

                                          @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 in lib/plugins? I think it only needs to go into lib/plugins/sqldrivers and there's no reason to have a second libQt5Sql.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??

                                          A Offline
                                          A Offline
                                          ambershark
                                          wrote on last edited by
                                          #34

                                          @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 in lib/plugins? I think it only needs to go into lib/plugins/sqldrivers and there's no reason to have a second libQt5Sql.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.

                                          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                                          kshegunovK 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved