Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: QMYSQL Driver (undefined symbol: mysql_server_init)

  1. #21
    Join Date
    Jul 2010
    Location
    Serbia, Belgrade
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    I have this errors:

    Qt Code:
    1. /home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3:
    2. /home/miroslav/dekis/Dekis/connector.h:3: error: QSqlDatabase: No such file or directory
    3. /home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3:
    4. /home/miroslav/dekis/Dekis/connector.h:9: error: ‘QSqlDatabase’ has not been declared
    5. /home/miroslav/dekis/Dekis/connector.h:11: error: ‘QSqlDatabase’ was not declared in this scope
    6. /home/miroslav/dekis/Dekis/connector.h:11: error: expected ‘;’ before ‘db’
    7. /home/miroslav/dekis/Dekis/connector.h:12: error: ‘db’ was not declared in this scope
    8. /home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’
    9. /home/miroslav/dekis/Dekis/main.cpp:13: error: ‘w’ was not declared in this scope
    10. /home/miroslav/dekis/Dekis/main.cpp:12: error: ‘MainWindow’ was not declared in this scope
    11. /home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’
    To copy to clipboard, switch view to plain text mode 

  2. #22
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Wiki edits
    1

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    Can you post/attach your mainwindow.h and project file (*.pro)?

    It looks like you don't add sql module in your project file.

  3. #23
    Join Date
    Jul 2010
    Location
    Serbia, Belgrade
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    mainwindow.h

    Qt Code:
    1. /****************************************************************************
    2. ** Form interface generated from reading ui file 'mainwindow.ui'
    3. **
    4. ** Created: Sat Jul 24 19:27:05 2010
    5. **
    6. ** WARNING! All changes made in this file will be lost!
    7. ****************************************************************************/
    To copy to clipboard, switch view to plain text mode 

    Dekis.pro
    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.01a) Tue Jul 20 19:42:45 2010
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET =
    7. DEPENDPATH += .
    8. INCLUDEPATH += .
    9.  
    10. # Input
    11. HEADERS += connector.h mainwindow.h
    12. FORMS += mainwindow.ui
    13. SOURCES += main.cpp mainwindow.cpp
    To copy to clipboard, switch view to plain text mode 

  4. #24
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Wiki edits
    1

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    Quote Originally Posted by miroslavgojic View Post
    mainwindow.h

    Qt Code:
    1. /****************************************************************************
    2. ** Form interface generated from reading ui file 'mainwindow.ui'
    3. **
    4. ** Created: Sat Jul 24 19:27:05 2010
    5. **
    6. ** WARNING! All changes made in this file will be lost!
    7. ****************************************************************************/
    To copy to clipboard, switch view to plain text mode 
    Where is your MainWindow class declaration?

    Quote Originally Posted by miroslavgojic View Post
    Dekis.pro
    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.01a) Tue Jul 20 19:42:45 2010
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET =
    7. DEPENDPATH += .
    8. INCLUDEPATH += .
    9.  
    10. # Input
    11. HEADERS += connector.h mainwindow.h
    12. FORMS += mainwindow.ui
    13. SOURCES += main.cpp mainwindow.cpp
    To copy to clipboard, switch view to plain text mode 
    Add the the following line in Dekis.pro

    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 

  5. #25
    Join Date
    Jul 2010
    Location
    Serbia, Belgrade
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    I was not make changes in MainWindow class declaration.

  6. #26
    Join Date
    Jul 2010
    Location
    Serbia, Belgrade
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    after I add

    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    to Dekis.pro

    I have next errors (it is less then before)
    Qt Code:
    1. /home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3:
    2. /home/miroslav/dekis/Dekis/connector.h:11: error: expected primary-expression before ‘.’ token
    3. /home/miroslav/dekis/Dekis/main.cpp:12: error: ‘MainWindow’ was not declared in this scope
    4. /home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’
    5. /home/miroslav/dekis/Dekis/main.cpp:13: error: ‘w’ was not declared in this scope
    To copy to clipboard, switch view to plain text mode 

  7. #27
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Wiki edits
    1

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    Quote Originally Posted by miroslavgojic View Post
    I was not make changes in MainWindow class declaration.
    Stay to the same question, where is the MainWindow class declaration?

    Quote Originally Posted by miroslavgojic View Post
    after I add

    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    to Dekis.pro

    I have next errors (it is less then before)
    Qt Code:
    1. /home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3:
    2. /home/miroslav/dekis/Dekis/connector.h:11: error: expected primary-expression before ‘.’ token
    3. /home/miroslav/dekis/Dekis/main.cpp:12: error: ‘MainWindow’ was not declared in this scope
    4. /home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’
    5. /home/miroslav/dekis/Dekis/main.cpp:13: error: ‘w’ was not declared in this scope
    To copy to clipboard, switch view to plain text mode 
    Just try to create new project based on your old project. Your mainwindow.h is empty (except the comments).

  8. The following user says thank you to saa7_go for this useful post:

    miroslavgojic (28th July 2010)

  9. #28
    Join Date
    Jul 2010
    Location
    Serbia, Belgrade
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    After creating new project everything now work

    Thanks,

    This code working :

    connector.h
    Qt Code:
    1. #ifndef CONNECTOR_H
    2. #define CONNECTOR_H
    3. #include <QSqlDatabase>
    4. #include <QMessageBox>
    5.  
    6.  
    7. bool createConnection()
    8. {
    9. if (QSqlDatabase::isDriverAvailable("QMYSQL"))
    10. {
    11. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    12. db.setHostName("localhost");
    13. db.setDatabaseName("test");
    14. db.setUserName("test");
    15. db.setPassword("test");
    16.  
    17. if (!db.open())
    18. {
    19. m.setText("error I");
    20. m.exec();
    21. return false;
    22. }
    23. else
    24. {
    25. return true;
    26. }
    27. }
    28. else
    29. {
    30. m.setText("error II");
    31. m.exec();
    32. return false;
    33. }
    34.  
    35. }
    36.  
    37. #endif // CONNECTOR_H
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3. #include "connector.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. if (!createConnection())
    9. return 1;
    10. MainWindow w;
    11. w.show();
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. MainWindow::~MainWindow()
    12. {
    13. delete ui;
    14. }
    15.  
    16. void MainWindow::changeEvent(QEvent *e)
    17. {
    18. QMainWindow::changeEvent(e);
    19. switch (e->type()) {
    20. case QEvent::LanguageChange:
    21. ui->retranslateUi(this);
    22. break;
    23. default:
    24. break;
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

    baza.pro
    Qt Code:
    1. # -------------------------------------------------
    2. # Project created by QtCreator 2010-07-26T09:33:19
    3. # -------------------------------------------------
    4. QT += network \
    5. opengl \
    6. sql \
    7. script \
    8. scripttools \
    9. svg \
    10. webkit \
    11. testlib \
    12. dbus
    13. TARGET = baza
    14. TEMPLATE = app
    15. SOURCES += main.cpp \
    16. mainwindow.cpp
    17. HEADERS += mainwindow.h \
    18. connector.h
    19. FORMS += mainwindow.ui
    To copy to clipboard, switch view to plain text mode 

  10. #29
    Join Date
    Jul 2010
    Location
    Serbia, Belgrade
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: QMYSQL Driver (undefined symbol: mysql_server_init)

    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 ...

Similar Threads

  1. Help with QMYSQL driver for QT 4.4.0: driver not loaded
    By khikho in forum Installation and Deployment
    Replies: 4
    Last Post: 1st April 2011, 16:00
  2. Replies: 1
    Last Post: 22nd June 2010, 20:56
  3. QtPlugin and undefined symbol
    By Mikoskay in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2010, 13:04
  4. QMYSQL driver
    By pcaeiro in forum Qt Programming
    Replies: 2
    Last Post: 3rd September 2009, 15:35
  5. undefined symbol in library
    By quickNitin in forum General Programming
    Replies: 1
    Last Post: 16th November 2006, 11:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.