Static build with mysql
-
I have a project that is working well and fine with dynamic libraries, but now I want to deploy it using static libraries.
I tried to build Qt static but I can't get it to have mysql drivers.I followed these instructions https://retifrav.github.io/blog/2018/02/17/build-qt-statically/ but on configure summary I have
Qt Sql: 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
How should I proceed?
Edit:
Forgot to mention - I'm on a Lubuntu (ubuntu) 18.04 with Qt 5.11.2. -
Hi and welcome to devnet,
Do you have the MySQL development libraries installed on your machine ?
By the way, don't forget the constraints of the LGPL regarding static builds of your application.
-
Didn't have those libraries, but now I believe I do (libmysqlclient-dev).
From what I gathered, I should now build the mysql plugin as static, somewhere in {qt folder}/qtbase/src/plugins/sqldrivers, and then when I build static Qt it will find the relevant static libraries for MySql. Am I correct?
But I can't find how to build the static mysql plugin for Qt. Any hint on how to do this?
As for the licenses, the app will be of very limited, internal use, so I guess no worries about that.
-
No, you build all of Qt statically from the start. In the absolute, you should start with only qtbase and then add the other modules you might need. You can also use the -skip option to avoid building everything that you don't need and do a one pass build.
-
@caiomarcos
I don't know, but should you have a read through the findings in https://forum.qt.io/topic/94378/qt-static-with-mysql-issue ? -
@kshegunov good point, I misread that part of @caiomarcos post. I'm not even sure Linux distributions provides static versions of their libraries (I highly doubt that).
So to answer that point, no, building a static Qt doesn't mean that it will look for all its dependencies as static libraries too.
That's a subtlety many new developers don't know: a static library can have dynamic dependencies and if you want a full static library you have to get all its dependencies as full static libraries too.
-
Thank you all.
I had no idea it would be this much trouble.
My experience is in microcontroller programming, bare metal and the eventual RTOS, so all this is very foreign to me.
I guess I'll figure out something else, maybe prepare the environment throughout on the target instead of relying on a static build or whatever.
Thanks again, I'll leave this for later.
-
@caiomarcos
he got succeed , but i can't get what he did.FYR
https://forum.qt.io/topic/94378/qt-static-with-mysql-issue