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. Error compiling libqsqlmysql.so ( On Ubuntu)
Forum Updated to NodeBB v4.3 + New Features

Error compiling libqsqlmysql.so ( On Ubuntu)

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 310 Views
  • 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.
  • C Offline
    C Offline
    CristianoNarcisiVidex
    wrote on 10 Oct 2019, 09:33 last edited by aha_1980 10 Oct 2019, 16:31
    #1

    Hi all
    i am writing a stupid thread that needs to read some settings from a mysql database. Here i have snippet of code:

    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
    
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setDatabaseName("mydb");
        db.setUserName("root");
        db.setPassword("root");
        db.setHostName("localhost:50000");
    
        if(db.open())
        {
            qDebug() << "ok";
        }
        else
        {
            qDebug() << "ko";
        }
        return a.exec();
    }
    

    This code prints "ko". The very strange thing is that replacing QMYSQL with QSQLITE the database connection is correctly opened! I was wondering if the problem is on the connector. I have made ldd on libqsqlmysql.so and this is the output:

    ~/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so
    
    linux-vdso.so.1 =>  (0x00007fffc5fdc000)
    	libQt5Sql.so.5 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007fe96e0c5000)
    	libQt5Core.so.5 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007fe96d932000)
    	libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007fe96d2e8000)
    	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe96cf65000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe96cb9b000)
    	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe96c97e000)
    	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe96c674000)
    	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe96c45e000)
    	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe96c244000)
    	libicui18n.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007fe96bdaa000)
    	libicuuc.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007fe96b9f2000)
    	libicudata.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007fe96a00f000)
    	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe969e0a000)
    	libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fe969c08000)
    	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fe9698f7000)
    	/lib64/ld-linux-x86-64.so.2 (0x000055668565a000)
    	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe969686000)
    
    

    As you can see, all the dependencies are respected.

    What am i doing wrong?
    i think that i am making a very stupid error.

    Sorry for wasting you all time.

    Thanks

    Cristiano

    J J 2 Replies Last reply 10 Oct 2019, 10:23
    0
    • C CristianoNarcisiVidex
      10 Oct 2019, 09:33

      Hi all
      i am writing a stupid thread that needs to read some settings from a mysql database. Here i have snippet of code:

      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
      
          QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
          db.setDatabaseName("mydb");
          db.setUserName("root");
          db.setPassword("root");
          db.setHostName("localhost:50000");
      
          if(db.open())
          {
              qDebug() << "ok";
          }
          else
          {
              qDebug() << "ko";
          }
          return a.exec();
      }
      

      This code prints "ko". The very strange thing is that replacing QMYSQL with QSQLITE the database connection is correctly opened! I was wondering if the problem is on the connector. I have made ldd on libqsqlmysql.so and this is the output:

      ~/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so
      
      linux-vdso.so.1 =>  (0x00007fffc5fdc000)
      	libQt5Sql.so.5 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007fe96e0c5000)
      	libQt5Core.so.5 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007fe96d932000)
      	libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007fe96d2e8000)
      	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe96cf65000)
      	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe96cb9b000)
      	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe96c97e000)
      	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe96c674000)
      	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe96c45e000)
      	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe96c244000)
      	libicui18n.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007fe96bdaa000)
      	libicuuc.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007fe96b9f2000)
      	libicudata.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007fe96a00f000)
      	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe969e0a000)
      	libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fe969c08000)
      	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fe9698f7000)
      	/lib64/ld-linux-x86-64.so.2 (0x000055668565a000)
      	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe969686000)
      
      

      As you can see, all the dependencies are respected.

      What am i doing wrong?
      i think that i am making a very stupid error.

      Sorry for wasting you all time.

      Thanks

      Cristiano

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 10 Oct 2019, 10:23 last edited by
      #2

      @CristianoNarcisiVidex What does https://doc.qt.io/qt-5/qsqldatabase.html#lastError say (after open())?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • C CristianoNarcisiVidex
        10 Oct 2019, 09:33

        Hi all
        i am writing a stupid thread that needs to read some settings from a mysql database. Here i have snippet of code:

        int main(int argc, char *argv[])
        {
            QCoreApplication a(argc, argv);
        
        
            QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
            db.setDatabaseName("mydb");
            db.setUserName("root");
            db.setPassword("root");
            db.setHostName("localhost:50000");
        
            if(db.open())
            {
                qDebug() << "ok";
            }
            else
            {
                qDebug() << "ko";
            }
            return a.exec();
        }
        

        This code prints "ko". The very strange thing is that replacing QMYSQL with QSQLITE the database connection is correctly opened! I was wondering if the problem is on the connector. I have made ldd on libqsqlmysql.so and this is the output:

        ~/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so
        
        linux-vdso.so.1 =>  (0x00007fffc5fdc000)
        	libQt5Sql.so.5 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007fe96e0c5000)
        	libQt5Core.so.5 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007fe96d932000)
        	libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 (0x00007fe96d2e8000)
        	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe96cf65000)
        	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe96cb9b000)
        	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe96c97e000)
        	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe96c674000)
        	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe96c45e000)
        	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe96c244000)
        	libicui18n.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007fe96bdaa000)
        	libicuuc.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007fe96b9f2000)
        	libicudata.so.56 => /home/cristiano/Qt_5.12/5.12.2/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007fe96a00f000)
        	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe969e0a000)
        	libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fe969c08000)
        	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fe9698f7000)
        	/lib64/ld-linux-x86-64.so.2 (0x000055668565a000)
        	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe969686000)
        
        

        As you can see, all the dependencies are respected.

        What am i doing wrong?
        i think that i am making a very stupid error.

        Sorry for wasting you all time.

        Thanks

        Cristiano

        J Offline
        J Offline
        JonB
        wrote on 10 Oct 2019, 11:09 last edited by
        #3

        @CristianoNarcisiVidex

        db.setHostName("localhost:50000");
        The very strange thing is that replacing QMYSQL with QSQLITE the database connection is correctly opened!

        So you have both QMYSQL and QSQLITE listening on the same port number?? Or, you have QSQLITE listening there, hence it's wrong for QMYSQL?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          CristianoNarcisiVidex
          wrote on 10 Oct 2019, 12:13 last edited by
          #4

          Re: Error compiling libqsqlmusql.so ( On Ubuntu)

          Hi All

          As i have predicted before, there was a very stupid error! It seems that

           db.setHostName("localhost:50000");
          

          is not valid using QMYSQL, but is valid for QSQLITE

          i have replaced it with

          db.setPort(50000);
           db.setHostName("localhost");
          

          And now i can connect to the db using the QMYSQL connector

          Sorry for bothering you!

          Thanks

          Cristiano

          1 Reply Last reply
          1

          1/4

          10 Oct 2019, 09:33

          • Login

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