Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Can't build libqsqlmysql.so



  • Hello.
    I'm newbie in Qt, I started to develop my app, which is intended to interact with MySQL database.
    I found, that I haven't mysql driver for Qt, so I read ton of topics and decided to compile it from Qt base.
    I have installed MariaDB 10.3, and I use MySQL everyday, and was surprised, that qmake didn't find it in system (Ubuntu 18.04):

    ~$ mysql --version
    mysql  Ver 15.1 Distrib 10.3.21-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
    

    So when I try to compile, I got this:

    ~/Qt/5.15.1/Src/qtbase/src/plugins/sqldrivers$ ../../../../../gcc_64/bin/qmake sqldrivers.pro 
    
    Running configuration tests...
    Checking for DB2 (IBM)... no
    Checking for InterBase... no
    Checking for MySQL... no
    Checking for OCI (Oracle)... no
    Checking for ODBC... no
    Checking for PostgreSQL... no
    Checking for SQLite (version 2)... no
    Checking for TDS (Sybase)... no
    Done running configuration tests.
    
    Configure summary:
    
    Qt Sql Drivers:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. no
      OCI (Oracle) ........................... no
      ODBC ................................... no
      PostgreSQL ............................. no
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    
    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into '/home/alexrsk/Qt/5.15.1/gcc_64'.
    

    Please advice, what I have to do to make it work.





  • $ which mysql
    /usr/bin/mysql
    
    :~/Qt/5.15.1/Src/qtbase/src/plugins/sqldrivers$ ../../../../../gcc_64/bin/qmake  -- MYSQL_PREFIX=/usr/bin/mysql
    

    Same thing:

    Qt Sql Drivers:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. no
      OCI (Oracle) ........................... no
      ODBC ................................... no
      PostgreSQL ............................. no
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    
    

    Also tried /usr/local, usr/local/bin, usr/local/sbin -- same results.



  • @Alex-Ryasky
    You are ignoring the most important part

    You need the MySQL / MariaDB header files, as well as the shared library libmysqlclient.so / libmariadb.so. Depending on your Linux distribution, you may need to install a package which is usually called "mysql-devel" or "mariadb-devel".
    Tell qmake where to find the MySQL / MariaDB header files and shared libraries (here it is assumed that MySQL / MariaDB is installed in /usr/local) and run make:

    They won't be in the bin folder. :)
    First you need to check that have you installed the dev* package.
    Also, as the Note says, remember to remove the config.cache before you run qmake again or it will always be a "no".
    And, as the Note says, again, you should open config.log to see what went wrong.
    Please try harder to solve the problem by yourself.

    Little tip added:
    *_PREFIX is used when you have the header file in PREFIX/include and the library file in PREFIX/lib.
    If they are not, then you should use *_INCDIR and *_LIBDIR to set the dirs.



  • Thank you very much, It helped a lot.



  • Next time i'll delve deeper into environments questions and rely to myself.



  • If the issue is solved, please mark it as solved :)


Log in to reply