View Full Version : QMYSQL Driver (undefined symbol: mysql_server_init)
przemek
8th July 2010, 19:40
Hello,
I have problem with app with mysql.
When I run app with mysql I get:
symbol lookup error: /usr/local/Trolltech/QtEmbedded-4.6.2-arm/plugins/sqldrivers/libqsqlmysql.so: undefined symbol: mysql_server_init
I run app on ARM-board with mysql ver. 14.14 distrib 5.1.40, for angstrom-linux-gnueabi (arm) using EditLine wrapper.
I built database drivers using:
qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysqlclient_r" mysql.pro
make
on Ubuntu without errors.
I don't know where is error.. Could you help me?
thanks,
Przemek
saa7_go
10th July 2010, 23:43
Try to recompile the driver using:
qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib -lmysqlclient_r" mysql.pro
make
przemek
15th July 2010, 00:06
Try to recompile the driver using:
qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib -lmysqlclient_r" mysql.pro
make
in result I get:
cannot find -lmysqlclient_r" :(
saa7_go
15th July 2010, 07:37
Is there any libmysql*.a in /usr/lib?
przemek
15th July 2010, 15:00
yes, in /usr/lib I have:
-rw-r--r-- 1 root root 2819966 2010-06-07 21:58 libmysqlclient.a
-rw-r--r-- 1 root root 1068 2010-06-07 21:57 libmysqlclient.la
-rw-r--r-- 1 root root 2834652 2010-06-07 21:58 libmysqlclient_r.a
-rw-r--r-- 1 root root 1122 2010-06-07 21:57 libmysqlclient_r.la
lrwxrwxrwx 1 root root 22 2010-07-08 16:31 libmysqlclient_r.so -> libmysqlclient_r.so.16
lrwxrwxrwx 1 root root 26 2010-07-08 16:31 libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
-rw-r--r-- 1 root root 2047772 2010-06-07 21:58 libmysqlclient_r.so.16.0.0
lrwxrwxrwx 1 root root 20 2010-07-08 16:31 libmysqlclient.so -> libmysqlclient.so.16
lrwxrwxrwx 1 root root 24 2010-07-08 16:31 libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
-rw-r--r-- 1 root root 2039580 2010-06-07 21:58 libmysqlclient.so.16.0.0
saa7_go
15th July 2010, 15:56
When I run app with mysql I get:
symbol lookup error: /usr/local/Trolltech/QtEmbedded-4.6.2-arm/plugins/sqldrivers/libqsqlmysql.so: undefined symbol: mysql_server_init
I think you successfully build qmysql driver. How did you build it?
przemek
15th July 2010, 21:07
My *cpp, *pro files and Makefile in attachments.
Do you think, that it could be problem with my linux on arm, or ubuntu, qt, or etc.?
I haven't got any idea how to solve my problem.
Maybe I should recompile all qt?
edit:
I recompile plugin on other computer and copy libqsqlmysql.so to arm-board and now I have message:
QSqlDatabase: QMYSQL driver not loaded
saa7_go
15th July 2010, 22:22
My *cpp, *pro files and Makefile in attachments.
Do you think, that it could be problem with my linux on arm, or ubuntu, qt, or etc.?
I haven't got any idea how to solve my problem.
Maybe I should recompile all qt?
edit:
I recompile plugin on other computer and copy libqsqlmysql.so to arm-board and now I have message:
QSqlDatabase: QMYSQL driver not loaded
I don't know. BTW, Do you use mysql from your host operating system(ubuntu) or angstrom?
miroslavgojic
20th July 2010, 21:35
Touday I tray to resolve this QMSQL
But no chance with qmake
I recive next message qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib -lmysqlclient_r" mysql.pro
Error processing project file: /usr/lib/qt4/plugins/sqldrivers/mysql/mysql.pro
and QT will not make application witout this mysql driver
I have ubuntu and QT4
Can somebody help
Please
saa7_go
21st July 2010, 06:14
Touday I tray to resolve this QMSQL
But no chance with qmake
I recive next message qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib -lmysqlclient_r" mysql.pro
Error processing project file: /usr/lib/qt4/plugins/sqldrivers/mysql/mysql.pro
and QT will not make application witout this mysql driver
I have ubuntu and QT4
Can somebody help
Please
Do you run qmake as root or using sudo?
miroslavgojic
24th July 2010, 18:00
I use
$ sudo su
for entering as root
saa7_go
24th July 2010, 18:24
Maybe, there is a problem with your mysql.pro. Can you attach it here?
miroslavgojic
24th July 2010, 19:53
I don't have mysql.pro
that file is not available on my Ubuntu,
saa7_go
24th July 2010, 19:55
What i mean is this /usr/lib/qt4/plugins/sqldrivers/mysql/mysql.pro. If mysql.pro doesn't exist, i assume you install Qt from your package management. Maybe you can search Qt MySQL plugin package using synaptic or something like that.
miroslavgojic
24th July 2010, 20:30
yes, I was install Qt from synaptic install manager
I install all package but mysql.pro is not present
and I have qt4 and qt3, can this make problems
saa7_go
24th July 2010, 20:39
I install all package but mysql.pro is not present.
and I have qt4 and qt3, can this make problems.
I'm not sure. But, have you search Qt4 MySQL plugin using synaptic?
miroslavgojic
24th July 2010, 20:48
I have look in synaptic and I have Qt mysql driver, it is installed at my Ubuntu
Qt4 Mysql database driver - this is name of synaptic package
saa7_go
24th July 2010, 20:55
So, you don't need to rebuilt Qt MySQL driver. Try to create simple application using MySQL driver.
miroslavgojic
24th July 2010, 21:06
I try to create simply application Qt and Mysql
and there I find some unexpected problems.
I make one project on C not C++, and it work, but this is not from QT, simply C code from gedit and gcc
I have one project in QT
one file is
connector.h
#ifndef CONNECTOR_H
#define CONNECTOR_H
#include <QSqlDatabase>
#include <QMessageBox>
bool createConnection()
{
if (QSqlDatabase::isDriverAvailable("QMYSQL"))
{
QSqlDatabase db = QSqlDatabase.addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("test");
db.setUserName("user");
db.setPassword("pass");
if (!db.open())
{
QMessageBox m;
m.setText("Greska I");
m.exec();
return false;
}
else
{
return true;
}
}
else
{
QMessageBox m;
m.setText("Nema drajver za DB");
m.exec();
return false;
}
}
#endif // CONNECTOR_H
and main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "connector.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if(!createConnection())
return 1;
MainWindow w;
w.show();
return a.exec();
}
and this project not work at QT
saa7_go
24th July 2010, 21:18
Are there any error/warning messages from your application?
miroslavgojic
24th July 2010, 22:19
I have this errors:
/home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3:
/home/miroslav/dekis/Dekis/connector.h:3: error: QSqlDatabase: No such file or directory
/home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3:
/home/miroslav/dekis/Dekis/connector.h:9: error: ‘QSqlDatabase’ has not been declared
/home/miroslav/dekis/Dekis/connector.h:11: error: ‘QSqlDatabase’ was not declared in this scope
/home/miroslav/dekis/Dekis/connector.h:11: error: expected ‘;’ before ‘db’
/home/miroslav/dekis/Dekis/connector.h:12: error: ‘db’ was not declared in this scope
/home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’
/home/miroslav/dekis/Dekis/main.cpp:13: error: ‘w’ was not declared in this scope
/home/miroslav/dekis/Dekis/main.cpp:12: error: ‘MainWindow’ was not declared in this scope
/home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’
saa7_go
25th July 2010, 04:13
Can you post/attach your mainwindow.h and project file (*.pro)?
It looks like you don't add sql module in your project file.
miroslavgojic
25th July 2010, 08:14
mainwindow.h
/************************************************** **************************
** Form interface generated from reading ui file 'mainwindow.ui'
**
** Created: Sat Jul 24 19:27:05 2010
**
** WARNING! All changes made in this file will be lost!
************************************************** **************************/
Dekis.pro
################################################## ####################
# Automatically generated by qmake (2.01a) Tue Jul 20 19:42:45 2010
################################################## ####################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += connector.h mainwindow.h
FORMS += mainwindow.ui
SOURCES += main.cpp mainwindow.cpp
saa7_go
25th July 2010, 09:02
mainwindow.h
/************************************************** **************************
** Form interface generated from reading ui file 'mainwindow.ui'
**
** Created: Sat Jul 24 19:27:05 2010
**
** WARNING! All changes made in this file will be lost!
************************************************** **************************/
Where is your MainWindow class declaration?
Dekis.pro
################################################## ####################
# Automatically generated by qmake (2.01a) Tue Jul 20 19:42:45 2010
################################################## ####################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += connector.h mainwindow.h
FORMS += mainwindow.ui
SOURCES += main.cpp mainwindow.cpp
Add the the following line in Dekis.pro
QT += sql
miroslavgojic
25th July 2010, 14:06
I was not make changes in MainWindow class declaration.
miroslavgojic
25th July 2010, 14:25
after I add
QT += sql
to Dekis.pro
I have next errors (it is less then before)
/home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3:
/home/miroslav/dekis/Dekis/connector.h:11: error: expected primary-expression before ‘.’ token
/home/miroslav/dekis/Dekis/main.cpp:12: error: ‘MainWindow’ was not declared in this scope
/home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’
/home/miroslav/dekis/Dekis/main.cpp:13: error: ‘w’ was not declared in this scope
saa7_go
26th July 2010, 03:47
I was not make changes in MainWindow class declaration.
Stay to the same question, where is the MainWindow class declaration?
after I add
QT += sql
to Dekis.pro
I have next errors (it is less then before)
/home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3:
/home/miroslav/dekis/Dekis/connector.h:11: error: expected primary-expression before ‘.’ token
/home/miroslav/dekis/Dekis/main.cpp:12: error: ‘MainWindow’ was not declared in this scope
/home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’
/home/miroslav/dekis/Dekis/main.cpp:13: error: ‘w’ was not declared in this scope
Just try to create new project based on your old project. Your mainwindow.h is empty (except the comments).
miroslavgojic
28th July 2010, 19:29
After creating new project everything now work
Thanks,
This code working :
connector.h
#ifndef CONNECTOR_H
#define CONNECTOR_H
#include <QSqlDatabase>
#include <QMessageBox>
bool createConnection()
{
if (QSqlDatabase::isDriverAvailable("QMYSQL"))
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("test");
db.setUserName("test");
db.setPassword("test");
if (!db.open())
{
QMessageBox m;
m.setText("error I");
m.exec();
return false;
}
else
{
return true;
}
}
else
{
QMessageBox m;
m.setText("error II");
m.exec();
return false;
}
}
#endif // CONNECTOR_H
main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "connector.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if (!createConnection())
return 1;
MainWindow w;
w.show();
return a.exec();
}
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
baza.pro
# -------------------------------------------------
# Project created by QtCreator 2010-07-26T09:33:19
# -------------------------------------------------
QT += network \
opengl \
sql \
script \
scripttools \
svg \
webkit \
testlib \
dbus
TARGET = baza
TEMPLATE = app
SOURCES += main.cpp \
mainwindow.cpp
HEADERS += mainwindow.h \
connector.h
FORMS += mainwindow.ui
miroslavgojic
28th July 2010, 20:25
Now, how to create query
what is procedure?
Is new *.h file for sql or I can use existing files in project ...
I have created database ... I need to manipulate with data in database ...
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.