[SOLVED]QSqlDatabase
-
For the qmake problem, simply provide the complete path to qmake when building the plugin
-
wrote on 17 Apr 2013, 15:52 last edited by
[quote author="SGaist" date="1366211235"]For the qmake problem, simply provide the complete path to qmake when building the plugin[/quote]
The thing is that i cannot find the plugin that is written here:
@cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:/MySQL/include" "LIBS+=C:/MYSQL/MySQL Server <version>/lib/opt/libmysql.lib" mysql.pro
nmake@i mean the 'mysql' in the sqldrivers folder...
-
Get the source package then, you'll find what you need in there
-
wrote on 17 Apr 2013, 19:22 last edited by
Could you provide me the right link? to know for sure that what i'm downloading is the right package :D
-
wrote on 17 Apr 2013, 20:05 last edited by
Hm, aren't you actually trying to connect to PostgreSQL and not MySQL? :)
-
wrote on 17 Apr 2013, 20:14 last edited by
well, for me it would be really the same if connecting postresql or mysql.
I was trying to make one of them work, but I couldn't find the way... -
wrote on 17 Apr 2013, 20:28 last edited by
OK, got confused cause your sample code tries to connect to Postrgre and then all the discussion was about MySQL. As SGaist suggested, you need the sources, but don't know where you can get them as I use the SDK which includes the sqldriver sources.
-
wrote on 17 Apr 2013, 20:29 last edited by
Can you than maybe link to me where to download the SDK from?
'cause today i tried 3-4 different Qts....and nothing :S -
wrote on 17 Apr 2013, 20:39 last edited by
Well, at the top of the download page you can choose a Windows SDK, nothing confusing there. However, are you sure you are searching in the right place for the mysql driver? If you already have an SDK installation, the full path to the MySQL driver folder is this
@
QtRootInstallationFolder/Src/qtbase/src/plugins/sqldrivers/mysql
@ -
wrote on 17 Apr 2013, 20:58 last edited by
haha, that's nice :D
ok, the files are there, so i just have to compile them with the 'qmake' through my windows terminal?
compiled it (i saw that with the normal terminal the qmake command didn't work, so i did it with the terminal provided by Qt), but now the final make command gives me an error lol@C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\mysql>make
make -f Makefile.Release all
make[1]: Entering directory/c/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/sqldrive rs/mysql' g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I'/usr/local/in clude' -I'C:/Qt/Qt5.0.2/5.0.2/mingw47_32/include' -I'C:/Qt/Qt5.0.2/5.0.2/mingw47 _32/include/QtSql' -I'C:/Qt/Qt5.0.2/5.0.2/mingw47_32/include/QtSql/5.0.2' -I'C:/ Qt/Qt5.0.2/5.0.2/mingw47_32/include/QtSql/5.0.2/QtSql' -I'C:/Qt/Qt5.0.2/5.0.2/mi ngw47_32/include/QtCore' -I'.moc/release_shared' -I'../../../../mkspecs/win32-g+ +' -o .obj/release_shared/main.o main.cpp In file included from main.cpp:44:0: ../../../sql/drivers/mysql/qsql_mysql.h:52:19: fatal error: mysql.h: No such fil e or directory compilation terminated. make[1]: *** [.obj/release_shared/main.o] Error 1 make[1]: Leaving directory
/c/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/sqldriver
s/mysql'
make: *** [release-all] Error 2
@ -
wrote on 17 Apr 2013, 21:17 last edited by
OK, one step closer :). I don't quite get what you mean with the terminal issue, but are you giving the path to the mysql include folder in your qmake command, as you wrote in a previous post?
@
"INCLUDEPATH+=C:/MySQL/include"
@
The mysql.h file should be in there. -
wrote on 17 Apr 2013, 21:18 last edited by
Well, there was no MySQL folder
i just downloaded a lot of packages, and so i will now retry :D
thanks -
wrote on 17 Apr 2013, 21:23 last edited by
OK
everything done, compiling with both qmake and make, and no errors came out :D
now, going back to Qt:
i've put one line of code to try the DB:
@void MainWindow::connectDB()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
}
@and the output is just:
@C:\Users\Nick\Documents\QT_Projects\HotelManagement\mainwindow.cpp:39: error: undefined reference to `_imp___ZN12QSqlDatabase17defaultConnectionE'@
is it something that i just don't get?
-
wrote on 17 Apr 2013, 21:29 last edited by
Are you including <QSqlDatabase> in the file where you are trying to establish the connection? Also,
try to get the list of available drivers with QSqlDatabase::drivers(). -
wrote on 17 Apr 2013, 21:38 last edited by
That's what I include:
!http://i47.tinypic.com/2hfnyhk.jpg(include)!And it still gives me error, for the drivers():
@C:\Users\Nick\Documents\QT_Projects\HotelManagement\mainwindow.cpp:38: error: undefined reference to `_imp___ZN12QSqlDatabase7driversEv'@ -
wrote on 17 Apr 2013, 21:43 last edited by
OMG, that was crazy haha
i had in my .pro file
@QT += core gui@
and i thought that i had to just add the 'sql' like the methods below...
and that's why it didn't work...
ooooh my gooodthanks a lot guys, and sorry for disturbing so much
SOLVED
-
wrote on 17 Apr 2013, 21:46 last edited by
Nice, don't forget to mark your thread's title as [SOLVED].
17/24