Qt 4.8.4 static build WITH MySQL pluing enabled using MinGw 4.6
-
Good day
I'm able to build Qt 4.8.4 statically with MinGW (similar to "these":http://wiki.batcom-it.net/index.php?title=Building_Qt_on_Windows_(MinGW) instructions). The issue is I want to use MySQL statically with it as well, but I'm not able to do that.
I compiled Qt with mysql plugin enabled. when trying to use it, I'm getting this error.@plugins/sqldrivers/libqsqlmysql.a(qsql_mysql.o):qsql_mysql.cpp:(.text+0x140): undefined reference to `mysql_stmt_insert_id@4'
@This is part of the .pro file
@TARGET = static-test
TEMPLATE = app
CONFIG += static
QTPLUGIN += qsqlmysql
LIBS += -LC:/mysql/lib/ -lmysqlclient
@What should I do next? should I try to compile mysqlclient with MinGW 4.6 as well?
Or should I go for VS 2010 build?
Thanks!
-
Tried to build with VS2010 and with MySQL enabled, and still getting the same error.
has anyone ever succeeded in doing this?
Thanks!
-
Hi,
You might be missing "this":http://qt-project.org/doc/qt-4.8/qtplugin.html#Q_IMPORT_PLUGIN
-
Hello
Nop, I have that added in the .cpp file
This is the whole example, its just a sample one to see how to use mysql statically@Q_IMPORT_PLUGIN(qsqlmysql)
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);QSqlDatabase db = QSqlDatabase::addDatabase( "MYSQL" ); qDebug() << QSqlDatabase::drivers();
}@
Thanks!
-
Just thinking of something: Do you have mysql in your PATH ? The plugin being static doesn't mean it has not any dependencies
-
Yes, if you look at the .pro file at the first post, you will see that I've included the path in it
@LIBS += -LC:/mysql/lib/ -lmysqlclient@and mysqlclient.lib is the static build of mysql (thats what I understood) :(
Thanks!
-
I mean the PATH environment variable, check that you have mysql in it.
No, not necessarily, on Windows it can be the static version or the "link to" version
-
Yep, I even copied the libmysql.lib and mysqlclient.lib into the system32 directory which is in the PATH env variable.
This is what I think, not sure if my assumptions are correct.
I need to build mysql statically using the same compiler which Mingw. but mysql only compiles under vs and cmake :(
what do you think? is that correct assumption?
Thanks!
-
It's not the lib you need in the PATH it's the dlls. You can simply copy them in the same folder as your application