Results 1 to 19 of 19

Thread: Connection to MySQL - windows

  1. #1
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Connection to MySQL - windows

    Hi everybody,

    Like many people in this forum, I have problem connecting to a mysql databasis.

    I have tried every tutorials I can find on internet but I have still the same error :
    "In file included from main.cpp:26:
    ../../../sql/drivers/mysql/qsql_mysql.h:34:19: mysql.h No such file or directory"

    I have Qt 4.1.1 OS on windows XP and MySQL 5.0.

    I did the steps listed at this adress:
    http://qtfr.org/forum/viewtopic.php?pid=8357 (in french)
    (or the same in english: http://www.korone.net/bbs/board.php?...ture&wr_id=173)

    For me, this is:

    cd c:\program*\mysql\mysql*\lib\opt
    reimp -d libmysql.lib
    dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a

    cd Qt\4.1.1
    configure -plugin-sql-mysql
    (I also tried: configure -plugin-sql-mysql -I C:\program*\mysql\mysql*\INCLUDE)

    cd c:\qt\4.1.1\src\plugins\sqldrivers\mysql
    qmake -o Makefile "INCLUDEPATH+=C:\program*\mysql\mysql*\INCLUDE " "LIBS+=-LC:\program*\mysql\mysql*\LIB\OPT -lmysql" mysql.pro

    cd Qt\4.1.1
    make

    And I get the error:
    "mysql.h No such file or directory"

    Like I said before, I have tried every thing I can and I don't know how to fix this error. So if someone can help me, I would really apreciate it.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Connection to MySQL - windows

    You can't use wildcards ("*"), you have to provide full path. Unfortunately something in the chain doesn't like whitespaces in paths, so you should move the files needed (or the whole installation) to another place - without white spaces and point the compilation there.

  3. #3
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connection to MySQL - windows

    OK thanks, I made a new instalation of MySQL in a path without whitespaces, and this time the compilation runed without error.

    But still, when I try to connect to the database, I get the error:
    "Driver not loaded Driver not loaded"

    Here is the code I use to make the connection:

    #include <QtGui>
    #include <QtSql>
    #include <QMessageBox>
    #include <QSqlDatabase>

    inline bool createConnection()
    {
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setUserName("root");
    db.setPassword("T23Y45");
    if (!db.open()) {
    QMessageBox::warning(0, QObject::tr("Database Error"), db.lastError().text());
    return false;
    }
    return true;
    }

    Is there something wrong?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Connection to MySQL - windows

    Please search this forum for issues related to MySQL driver and try to use solutions provided there. Maybe some of them will help. If not, then come back to this thread and try to describe what you tried and what were the results. Probably either the driver or some of its dependencies can't be found by your system.

  5. #5
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Connection to MySQL - windows

    Hi,

    Thank you After reading very posts. I have my driver loaded but I don't understand something. I have a question. MYSQL driver is loaded if I have Instaled mysql in the default C:\archivos de programa\mysql\mysql\mysql server 5.0 but also I need to have copy in C:\mysql\include ... and C:\mysql\lib ..... because qmake don't like spaces like C:\archivos de prova ex: qmake -o Makefile INCLUDEPATH+=C:\archivos de programa\mysql....

    Also I tried to install mysql to c:\mysql but I have a problem with driver not loaded. So I need to have two directories of mysql one is for default path installation and other for do the qmake

    Thank you

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Connection to MySQL - windows

    Quote Originally Posted by fpujol View Post
    because qmake don't like spaces
    I don't think it's qmake, more probably make itself.

    Also I tried to install mysql to c:\mysql but I have a problem with driver not loaded. So I need to have two directories of mysql one is for default path installation and other for do the qmake
    The problem is that during compilation time the compiler has to be able to find proper include files and libraries so that it can build the plugin. Because of some feature/bug, the build process doesn't accept whitespaces in path names. This is one thing.

    But the problem is also that those mysql libraries have to be found by the system, so that it can initialise the plugin when it is to be used by Qt. To do that, the system needs to be informed where those libraries are (that's what the installation process of MySQL does - it registers those libraries within the system).

    If you install MySQL in a place where both of the above mentioned conditions are met, you can have a single directory and a working driver without any special actions from your side. But if you fail to meet one of those conditions, the driver will either not compile or not run and you have to "patch" your system by copying appropriate files to appropriate places.

    So let me say it one last time, so that everyone having problems with MySQL driver under Windows can see the issue:

    Problems with compiling/running the MySQL (or any other) driver are not related to Qt but to faulty installation of MySQL or to bugs within the tool chain used to build the driver.
    You can get rid of all the problems by pointing MySQL installation to a proper (non-default) place, that doesn't contain whitespaces, like C:\MySQL in the first place!

  7. #7
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connection to MySQL - windows

    Hi,

    I actually installed MySQL in C:\MySQL. All the process of compilation went find:

    cd c:\mysql\lib\opt
    reimp -d libmysql.lib
    dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a

    cd c:\Qt\4.1.1
    configure -plugin-sql-mysql -I C:\mysql\INCLUDE

    cd c:\qt\4.1.1\src\plugins\sqldrivers\mysql
    qmake -o Makefile "INCLUDEPATH+=C:\mysql\INCLUDE " "LIBS+=-LC:\mysql\LIB\OPT -lmysql" mysql.pro

    cd C:\Qt\4.1.1
    make

    But there is still this damn error "driver not loaded".

    So I used QSqlDatabase::drivers() and found out there is no driver loaded.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Connection to MySQL - windows

    Is C:\MySQL\lib\opt in your system's library path?

  9. #9
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connection to MySQL - windows

    Ok, actually MySQL is installed in C:\MySQL\MySQL_server_5.0.
    I guess it's not a problem compared to C:\MySQL?

    Now, yes there is : C:\MySQL\MySQL_Server_5.0\lib\opt in the variable path.
    (start->control panel->system->advanced->environment variables->path)

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Connection to MySQL - windows

    Use a dependency walker to see if the driver can find all its dependencies.

  11. #11
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connection to MySQL - windows

    Thanks for your help but actually I don't really know where to look for the driver.

    But I tried to run the dependency walker on my program (myQtProgram.exe) and here is what it says:
    EFSADU.DLL: Error opening file, impossible to find the file
    Warning: At least one delay-load dependency module was not found.
    Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

    Then I tried to look for EFSADU.DLL on my computer but I don't have it.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Connection to MySQL - windows

    Quote Originally Posted by Peter34 View Post
    But I tried to run the dependency walker on my program (myQtProgram.exe)
    Try running it on the plugin with QMYSQL driver.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Connection to MySQL - windows

    Quote Originally Posted by Peter34 View Post
    Thanks for your help but actually I don't really know where to look for the driver.
    It should be in plugins\sqldrivers folder of your Qt installation. And you don't have to look for it manually - use a file search function your operating system offers. The file will probably be called qmysql.dll

  14. #14
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connection to MySQL - windows

    Ok there are 2 files in Plugins\SqlDrivers:
    qsqlmysql.dll and qmysqld.dll.

    I run the dependancy walker on both of them and the answer is always the same:

    EFSADU.DLL: Error opening file, impossible to find the file
    Warning: At least one delay-load dependency module was not found.
    Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

  15. #15
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    1
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connection to MySQL - windows

    Quote Originally Posted by Peter34 View Post
    Ok there are 2 files in Plugins\SqlDrivers:
    qsqlmysql.dll and qmysqld.dll.
    These are the release and debug builds of the driver.

    You didn't forget:

    Qt Code:
    1. QApplication app(argc, argv);
    To copy to clipboard, switch view to plain text mode 

    in your main() function, did you?

  16. #16
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Connection to MySQL - windows

    These are the release and debug builds of the driver.
    That's good to know.

    Yes I put:
    QApplication app(argc, argv);
    in the main function.
    Actually I am working with exemples from a Qt book so the syntax should be ok.

  17. #17
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Connection to MySQL - windows

    Does someone has an idea of what is going wrong.
    I read that window XP Home doesn't have the EFSADU.DLL file. And that may be the raison why the plugin doesn't work..

  18. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Connection to MySQL - windows

    I assure you the plugin works on WindowsXP Home.

  19. #19
    Join Date
    Oct 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Cool Re: Connection to MySQL - windows

    Finally! This is working!
    I just reinstall mysql in C:\MySQL then did the configuration and compilation, and it worked fine.

    Thanks for your help Wysota.

Similar Threads

  1. Embedded Mysql Windows Qt4.1
    By benguela in forum Qt Programming
    Replies: 7
    Last Post: 17th January 2007, 00:13
  2. Deploying with MySQL support under Windows
    By KShots in forum Installation and Deployment
    Replies: 1
    Last Post: 12th October 2006, 09:19
  3. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48
  4. Can I launch a dial-up connection in Windows?
    By gtthang in forum Qt Programming
    Replies: 3
    Last Post: 9th February 2006, 12:32
  5. Qt 4.1 OS on Windows & mysql
    By neeko in forum Installation and Deployment
    Replies: 10
    Last Post: 31st January 2006, 20:22

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.