Qt Static Build with SQL plugins/libs
-
Hi, when I use the Qt help framework (QT += help), I feel that I introduce some plugin stuff like the SQL database, which is supposed to be also statically linked into the application. Still have no idea how to do this. However, when I list the linked libraries of the static built application (using ldd), there are still some shared SQL libraries which are not shipped with the system, meaning if you move onto anther machine, still need to install them for the application to run.
libmysqlclient.so.20 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 libodbc.so.2 => /usr/lib/x86_64-linux-gnu/libodbc.so.2 libpq.so.5 => /usr/lib/x86_64-linux-gnu/libpq.so.5In the configure of Qt static library, I saw some options related to SQL database, but have no idea how they are related:
-sql-<driver> ........ Enable SQL <driver> plugin. Supported drivers: db2 ibase mysql oci odbc psql sqlite2 sqlite tds [all auto] -sqlite .............. Select used sqlite3 [system/qt]Is this the way or I should manually link to the static version of these SQL libraries? I'm using Qt5.12.0 on Ubunto16.04. Thanks.
-
Hi,
If you want a fully static application, then you have to link to all dependencies statically also.
Just remember that you also have to abide by the licensing constraints if you are using the (L)GPL version of Qt.
-
Hi,
If you want a fully static application, then you have to link to all dependencies statically also.
Just remember that you also have to abide by the licensing constraints if you are using the (L)GPL version of Qt.
Hi @SGaist Noted the license constraints with thanks.
May I know how to statically link this sql library? I can link all my other libraries statically but this one seems was linked by the Qt Help module and still not sure how to tell Qt to link the static version? I tried add
LIBS += .......libmysqlclient.abut it does not work. Qt still looks for the shared versionlibmysqlclient.so.20. -
Do you have both in the same folder ?
-
Then you should remove the dynamic version of the library.
-
IIRC, you would have to put the whole path to the file that needs to get linked.