Results 1 to 10 of 10

Thread: Creating MySQL driver returns error

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Creating MySQL driver returns error

    Hello!

    Some time ago I did a research in order to discover how to create the MySQL driver for Qt and after various failed helps I managed to find this website, whoose process to create such driver runs sucessfully:

    [http://ieatbinary.com/2011/07/11/how...-for-windows/]

    After doing this process succesfully in two different machine, for the first time I'm incapable of creating the driver pointing always the error that mysql.h is missing:
    Sem título.jpg

    Could somebody please point out what is the problem? Where can I find mysql.h? Could this be due to the MySQL installation folder is in F: and Qt installation is in C:?

    Thanks,

    Momergil

    Edit: at the end of the web page it is stated: "You can’t use MySQL 64 Bit (at the moment) to compile the plugin.". I'm not sure, but it is really probable that I'm using a 64 bit MySQL... Does somebody know if this restriction is still valid?
    Last edited by Momergil; 19th January 2013 at 15:57.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Creating MySQL driver returns error

    If the compiler is telling you it can't find mysql.h, it either means that you don't have developer API for MySQL installed (maybe you only have the actual run-time DBMS code), or you don't have the include path correctly specified in your makefile or .pro file.

    Did you follow the instructions at the link you provided *exactly*?

    It is irrelevant where your versions of Qt and MySQL are installed as long as you include the drive letter when you set up either the mysql environment variable or specify the include path.

    Of course, it is entirely possible that you installed 64-bit MySQL by mistake, but that has nothing to do with the problem you are having. I think the comment on that web site probably means the author has a 32-bit Qt installation. You cannot mix 32-bit and 64-bit EXE and DLL Windows modules, even on a 64-bit machine.

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating MySQL driver returns error

    Quote Originally Posted by d_stranz View Post
    If the compiler is telling you it can't find mysql.h, it either means that you don't have developer API for MySQL installed (maybe you only have the actual run-time DBMS code), or you don't have the include path correctly specified in your makefile or .pro file.
    Actually first I though that this was the problem: I didn't have the developer API, so today, thinking that that would fix the problem, I downloaded and installed this developer API.

    developer api.png

    But the same problem as before appeared, as if nothign had changed.

    Quote Originally Posted by d_stranz View Post
    Did you follow the instructions at the link you provided *exactly*?
    Yep. The only difference is that MySQL is installed in the F: and not in C: as in the instructions.

    Quote Originally Posted by d_stranz View Post
    It is irrelevant where your versions of Qt and MySQL are installed as long as you include the drive letter when you set up either the mysql environment variable or specify the include path.

    Of course, it is entirely possible that you installed 64-bit MySQL by mistake, but that has nothing to do with the problem you are having. I think the comment on that web site probably means the author has a 32-bit Qt installation. You cannot mix 32-bit and 64-bit EXE and DLL Windows modules, even on a 64-bit machine.
    Well, actually I think that my Qt is 32-bit version and MySQL is 64-bit :x

    qt version.jpg

    I'll give a look a the .pro file, since I found the mysql.h in the MySQL directory; maybe that's the problem.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Creating MySQL driver returns error

    I am not sure about the comment regarding 64-bit MySQL. If you build your Qt MySQL plugin as 32-bit code, unless using that plugin requires you to load a 64-bit DLL from the MySQL distribution, then it should be OK. But I do not know how MySQL implements run-time access to the database server. If it is some kind of socket-based connection, then a 64-bit MySQL and a 32-bit Qt plugin shouldn't be a problem But if the connection is based on an interface through a 64-bit MySQL DLL, then it won't work.

    If you build a 64-bit version of Qt, then you'll should be OK using a 64-bit MySQL. You just need to be sure that you have apples and apples everywhere, and not apples and oranges.

  5. #5
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating MySQL driver returns error

    Well, you were right about the .pro file: the include of mysql.h was not correct, so I redirected the link to MySQL folder in F: and the compilation went better, but a new problem arised:

    new problem.jpg

    It seems that the compiler has some problem with empty sapaces in the name, and the manual sad to "use short path"... So following this instructions [http://superuser.com/questions/34807...irectory-file] I put PROGRA~1 where there was "Program Files" and MYSQLS~1.5 where there was MySQL Server 5.5. Once again the last problem was corrected, but a new one appeared after dozens of "undefined reference to", and this time I have no idea what to do:

    new problem2.jpg

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Creating MySQL driver returns error

    Well, now you have a link-time problem - that's what an "undefined reference" is - you (or the plugin you're trying to build) have used something declared in a header file, but you haven't told the linker where to find the object or library file that contains its implementation. Whatever you did to tell qmake where to find the header files, you also need to tell it where to find the MySQL .lib files to link to. And you will probably have to do the same trick with the Program Files directory name that you did to get include files to work.

  7. #7
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating MySQL driver returns error

    Quote Originally Posted by d_stranz View Post
    Well, now you have a link-time problem - that's what an "undefined reference" is - you (or the plugin you're trying to build) have used something declared in a header file, but you haven't told the linker where to find the object or library file that contains its implementation. Whatever you did to tell qmake where to find the header files, you also need to tell it where to find the MySQL .lib files to link to. And you will probably have to do the same trick with the Program Files directory name that you did to get include files to work.
    Ouch... Well, I gave a look at qsql_mysql.cpp where the mingw was pointing this "undefined reference"s and followed thoose names (e.g. mysql_characterset_set_name) till reach mysql.h, where they are defined. So if I understood you correctly, what lacks is, so to speak, the mysql.cpp? Well I guess thoose implementations may be in libmysql.dll in "F:\Program Files\MySQL\MySQL Server 5.5\lib", what do you think? (you mentioned "you also need to tell it where to find the MySQL .lib files to link to" but I guess that was already told in the command line when I added "... "LIBS+=F:\PROGRA~1\MySQL\MYSQLS~1.5\lib\libmysql.l ib")

    In so being, how should I tell qmake to look for the implementations in this .dll?

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Creating MySQL driver returns error

    You do not need to include any source code (.cpp) files from your MySQL installation. Don't go down that road.

    "LIBS+=F:\PROGRA~1\MySQL\MYSQLS~1.5\lib\libmys ql.l ib"
    I do not use .pro files; I make Visual Studio projects out of everything, so I am not familiar with qmake syntax. But what you have there (assuming the extra space between "libmysql.l" and "ib" is just a cut-and-paste typo) looks OK to me.

    If I were you though, I would start over and reinstall MySQL to a folder that doesn't have any spaces anywhere in the name. You don't have to install to "Program Files" and don't have to use the name "MySQL Server 5.5". You can install to "F:\MySQL_Server_5_5" and then you won't have to worry about mangling the names to make qmake happy and you can set the "mysql" environment variable and use %mysql% in qmake arguments instead of hard-coded paths.

  9. #9
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating MySQL driver returns error

    Quote Originally Posted by d_stranz View Post
    You do not need to include any source code (.cpp) files from your MySQL installation. Don't go down that road.
    Yeah, I know, I just sad as for the argument

    Quote Originally Posted by d_stranz View Post
    But what you have there (assuming the extra space between "libmysql.l" and "ib" is just a cut-and-paste typo) looks OK to me.
    yeah, I didn't noticed the space, but it was actually a mistake; you can see the printscreens that I don't put the spaces in the code.

    But if it's OK, than I got a problem, because I already put that line of code in the process and with that line it didn't work :T

    Quote Originally Posted by d_stranz View Post
    If I were you though, I would start over and reinstall MySQL to a folder that doesn't have any spaces anywhere in the name. You don't have to install to "Program Files" and don't have to use the name "MySQL Server 5.5". You can install to "F:\MySQL_Server_5_5" and then you won't have to worry about mangling the names to make qmake happy and you can set the "mysql" environment variable and use %mysql% in qmake arguments instead of hard-coded paths.
    Well, while that can be done, I don't see actually good reasons for doing so. After all, the spaces problem is being solved using "short path", and the environment variable would be just a help, not anything that should make it work (actually you may re-read the instructional webpage and see that the guy there actually did use such environment variable). But once again, it doesn't seems to me that it would help with the actual problem - not to mension that would begin to crap my hard-disk's organization...

  10. #10
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating MySQL driver returns error

    Hello!

    Just to give my feedback,

    today I managed to install the mysql driver. The difference was that I follow one of the suggestions that were given to me: to uninstall current 64 mysql and install again the 32 mysql. After doing this, I managed to follow all the steps with no problem.


    Thanks for the help!

    Momergil

Similar Threads

  1. Replies: 1
    Last Post: 3rd March 2011, 11:41
  2. source code for odbc driver or MySql driver in arm-embedded-linux
    By sattu in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th January 2011, 10:11
  3. [QT 4.6] Error build driver mysql
    By vinny gracindo in forum Installation and Deployment
    Replies: 1
    Last Post: 26th February 2010, 01:02
  4. Error Loading MySql Driver in 4.3.4
    By perrigo in forum Qt Programming
    Replies: 5
    Last Post: 26th March 2008, 14:38
  5. mysql driver and nmake error
    By Ghost in forum Installation and Deployment
    Replies: 13
    Last Post: 13th March 2008, 14:23

Tags for this Thread

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.