Problem with MySQL driver for unixODBC on Debian Lenny - mysql

On OpenSuse 11.2, I successfully compiled, linked, and ran the following code which installs a data source for a MySQL database with unixODBC:
#include <iostream>
#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>
/* Add a data source for the following MySQL db: db=testdb, username=test, password = test. */
void inst()
{
BOOL ret = SQLConfigDataSource(NULL, ODBC_ADD_DSN, "MySQL driver",
"DSN=mysource\0UID=test\0PWD=test\0DATABASE=testdb\0\0");
if (!ret) {
DWORD errCode;
char errBuf[SQL_MAX_MESSAGE_LENGTH];
WORD msgLen;
SQLInstallerError(1, &errCode, errBuf, SQL_MAX_MESSAGE_LENGTH, &msgLen);
std::cerr << errBuf << std::endl;
}
}
int main()
{
inst();
return 0;
}
With the same code on Debian Lenny, I have had problems. First, I compiled this code the following way:
c++ -o main main.cc -lodbc -lodbcinst -L/usr/lib/odbc -lmyodbc
It went ok. But when I attempted to run the resulting binary, I got a linker error which in fact was confirmed by typing ldd main:
libmyodbc3_r-3.51.15.so => not found
Although I correctly installed unixODBC and the associated MySQL driver (myodbc) on my host (Debian Lenny) the simplest way (i.e. via aptitude), I could not find this shared library.
I wrongly thought, well, I will create a symlink on /usr/lib/odbc/libmyodbc.so. Anyway now my program returns the following message:
General installer error
So I feel the file libmyodbc3_r-3.51.15.so is really missing.
Note: on Debian Lenny, the version of unixODBC is 2.2.11, and the version of MySQL is 5.0.51a
Anyone ever ran into such a situation ? Any help would be appreciated.

The option
-L/usr/lib/odbc
tells the compiler where to find the library for linking.
But the system doesn't know where to find the library when you run the executable.
You need to either statically link against libmyodbc, or tell the system where to find the library.
The first can be done by changing
-lmyodbc
to
-static -lmyodbc
The second can be done by editing /etc/ld.so.conf (or adding to /etc/ld.so.conf.d) and re-running ldconfig or by setting the LD_LIBRARY_PATH environment variable to include /usr/lib/odbc

Related

Connecting to mysql database with c program

I would like to connect the mysql database using C in CodeBlocks
I downloaded MySQL Connector C 6.1
I added this below to my linker settings
I added this to Compiler in Search directories
I copied libmysql.dll to my project directory and /windows/system
I added #include "mysql.h" to my hello world example and tried to compile it.
#include <stdio.h>
#include <stdlib.h>
#include "mysql.h"
int main()
{
printf("Hello world!\n");
return 0;
}
When I try to compile it I get following errors:
cannot find -l-lmysqlpp
cannot find -l-lmysqlclient
I would be grateful for any help.
EDIT:
Let me upload my test_build_log.html file
-------------- Build: Debug in test (compiler: GNU GCC Compiler)---------------
gcc.exe -o bin\Debug\test.exe obj\Debug\main.o "C:\Program Files\MySQL\MySQL Connector C 6.1\lib\libmysql.lib" "C:\Program Files\MySQL\MySQL Connector C 6.1\lib\vs12\mysqlclient.lib" -l-lmysqlpp -l-lmysqlclient
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -l-lmysqlpp
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -l-lmysqlclient
collect2.exe: error: ld returned 1 exit status
cannot find -l-lmysqlpp
cannot find -l-lmysqlclient
These should be presented to the linker as:
-lmysqlpp
-lmysqlclient
The repeating -l switch indicates something wrong in your linker settings. Make sure there are no entries (including spaces or other hidden characters) in both link library an d Other linker options boxes. You may need to clear and re-enter everything in each box.
One more think to try, view the actual compile command line that is being used:
Code::Blocks can output a build log. Settings->Compiler and debugger->Global compiler settings->{slide tabs to the right}->Build options tab->Save build log to HTML. Turn this feature on, then view the log after your next attempt. There may be something there pointing to the problem.

C code using gcc cannot link to mysql header?

I'd like to build on this post, because my symptoms are identical, but the solution seems to be something else.
I am working in a Ubuntu container (Ubuntu 16.04.3 LTS), trying to compile a toy C program that will eventually connect to an SQL server. First things first: I have the latest libmysqlclient-dev installed:
root#1234:/home# apt install libmysqlclient-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libmysqlclient-dev is already the newest version (5.7.24-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 88 not upgraded.
root#1234:/home#
And when I look in the /usr/include/mysql directory, I see the critical header file I'll need:
root#1234:/home# ls -l /usr/include/mysql | grep mysql.h
-rw-r--r-- 1 root root 29207 Oct 4 05:48 /usr/include/mysql/mysql.h
root#1234:/home#
So far, so good. Now I found this little toy program from here:
#include <stdio.h>
#include "/usr/include/mysql/mysql.h"
int main() {
MYSQL mysql;
if(mysql_init(&mysql)==NULL) {
printf("\nInitialization error\n");
return 0;
}
mysql_real_connect(&mysql,"localhost","user","pass","dbname",0,NULL,0);
printf("Client version: %s",mysql_get_client_info());
printf("\nServer version: %s",mysql_get_server_info(&mysql));
mysql_close(&mysql);
return 1;
}
Now, following the advice of the previous post, I compile using the "-I" option to point to the mysql.h header file. (Yes, I am required to use GCC here):
root#1234:/home# gcc -I/usr/include/mysql sqlToy.c
/tmp/cc8c5JmT.o: In function `main':
sqlToy.c:(.text+0x25): undefined reference to `mysql_init'
sqlToy.c:(.text+0x69): undefined reference to `mysql_real_connect'
sqlToy.c:(.text+0x72): undefined reference to `mysql_get_client_info'
sqlToy.c:(.text+0x93): undefined reference to `mysql_get_server_info'
sqlToy.c:(.text+0xb4): undefined reference to `mysql_close'
collect2: error: ld returned 1 exit status
root#1234:/home#
Belly flop! The compiler has no idea what all the mySQL functions are, even though I've done all I can think of to point to that header file. As a sanity check, I made sure those mySQL functions are indeed in that header file; here's one as an example:
root#1234:/home# more /usr/include/mysql/mysql.h | grep mysql_init
libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
MYSQL * STDCALL mysql_init(MYSQL *mysql);
root#1234:/home#
So while I've pointed the compiler to the mysql.h header file in both my code AND with the "-I" option, it still has no clue what those 'mysql' functions are. The "-I" option was the solution in the previous post, but is not working for me here.
So... What might be the problem? I'm assuming this isn't a compiling problem, but maybe a linking one? In other words, I'm showing GCC where the mysql.h file is, but he is still not using it when processing the code?
Headers are not libraries. You are including the MySQL header during compilation, so these functions are defined, but you are not linking against the library which actually provides those functions.
These functions are provided by the libmysqlclient library, so you need to add the -lmysqlclient flag to your command line to fix this. (Note that this is a lower-case l, not an I.)
Additionally, since you are adding /usr/include/mysql to your system header path, you can include the library as
#include <mysql.h>
You do not need to -- and should not! -- specify the full path to the library in the #include directive.

Qt application with QSqlDatabase does not work properly when building it with macdeployqt

In my application I am using a QSqlDatabase to store some information. I did built it successfully with the following command (no errors even with verbose=3):
macdeployqt AppName.app/ -dmg -qmldir=~/dev/AppName/qml
Before that I successfully installed mysql55 using port
sudo port install mysql55
If I try to run my application it does not crash, but it also does not anything which involves database access.
This is my code for opening a database etc:
#include <QSqlQuery>
#include <QSqlDriver>
const QString DATABASE_NAME = "com.company.program.db";
MyClass::MyClass(QObject *parent) : QObject(parent) {
mDB = QSqlDatabase::addDatabase("QSQLITE");
#ifdef Q_OS_LINUX
QString path(QDir::home().path());
path.append(QDir::separator()).append(DATABASE_NAME);
path = QDir::toNativeSeparators(path);
mDB.setDatabaseName(path); // NOTE: We have to store database file into user home folder in Linux
#else
mDB.setDatabaseName(DATABASE_NAME); // NOTE: File exists in the application private folder, in Symbian Qt implementation
#endif
bool notOpened = !mDB.open();
QMessageBox::critical(0, "MyClass", mDB.lastError().databaseText()); // always is 'out of memory'
if (notOpened) emit failedToOpen();
else {
// some initialization
}
}
MyClass::~MyClass() {
mDB.close();
}
Has anyone experienced the same issues / a fix for this one?
Note: I am using Mac OS X 10.9 and Qt5.3.2
The Database Drivers are loaded at run-time. You won't get any database-config related errors during the compilation process, if the db-driver paths' are not correct.
The paths' can't even be incorrect, as you build on a machine where Qt is installed.
On Windows this occurs often, when the exe can't access files in plugins\sqldrivers.
Is there something like Linux's 'strace' on MAC? If yes, you could trace, in which paths your exe attempts to find driver plugins.
I always copy the entire plugin directory in installer and deploy it in the root-directory of the executable e.g. C:\Program Files (x86)\\plugins
Hope it helps.
I managed to fix the out of memory error by executing this code:
#ifdef Q_OS_MAC
QString databaseName = QApplication::applicationDirPath().append("/").append(DATABASE_NAME);
mDB.setDatabaseName(databaseName);
#endif

Setting up Mysql++ in linux

I want to connect to a mysql database with C++ in linux. On my local machine I am running Ubuntu, and installed the mysql server and client packages:
sudo apt-get install mysql-server mysql-client
I came across Mysql++ but have some problems when running ./configure from their binary package. The error says:
checking for MySQL library directory... configure: error: Didn't find mysqlclient library in '/usr/lib64 /usr/lib /usr/lib64/mysql /usr/lib/mysql /usr/local/lib64 /usr/local/lib /usr/local/lib/mysql /usr/local/mysql/lib /usr/local/mysql/lib/mysql /usr/mysql/lib/mysql /opt/mysql/lib /opt/mysql/lib/mysql /sw/lib /sw/lib/mysql'
I see where I can use this command to specify the path:
./configure --with-mysql-lib=/...
but I do not know where to point it to. I used whereis mysql but cannot find any mysql directory that contains a lib subdirectory. Where would the mysqlclient libraries be installed?
EDIT:
After doing locate libmysqlclient I got back
/usr/lib/i386-linux-gnu/libmysqlclient.so.18
/usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18.0.0
/usr/share/doc/libmysqlclient18
/usr/share/doc/libmysqlclient18/changelog.Debian.gz
/usr/share/doc/libmysqlclient18/copyright
/var/cache/apt/archives/libmysqlclient18_5.5.22-0ubuntu1_i386.deb
/var/lib/dpkg/info/libmysqlclient18:i386.list
/var/lib/dpkg/info/libmysqlclient18:i386.md5sums
/var/lib/dpkg/info/libmysqlclient18:i386.postinst
/var/lib/dpkg/info/libmysqlclient18:i386.postrm
/var/lib/dpkg/info/libmysqlclient18:i386.shlibs
So, I tried ./configure --with-mysql-lib=/usr/lib/i386-linux-gnu and it seems to complete without any complaining.
Although this solves the problem of getting ./configure to complete, I still have further troubles. When I run make things go fine until this point:
In file included from ./lib/sql_buffer.h:31:0,
from ./lib/sql_buffer.cpp:26: ./lib/refcounted.h:258:2: error: ‘size_t’ does not name a type
./lib/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer::RefCountedPointer()’: ./lib/refcounted.h:89:2: error:
class ‘mysqlpp::RefCountedPointer’ does not have any
field named ‘refs_’ ./lib/refcounted.h: In constructor
‘mysqlpp::RefCountedPointer::RefCountedPointer(T*)’:
./lib/refcounted.h:100:2: error: class ‘mysqlpp::RefCountedPointer’ does not have any field named ‘refs_’
./lib/refcounted.h:104:4: error: ‘refs_’ was not declared in this
scope ./lib/refcounted.h:104:16: error: expected type-specifier before
‘size_t’ ./lib/refcounted.h:104:16: error: expected ‘;’ before
‘size_t’ ./lib/refcounted.h: In constructor
‘mysqlpp::RefCountedPointer::RefCountedPointer(const
ThisType&)’: ./lib/refcounted.h:112:2: error: class
‘mysqlpp::RefCountedPointer’ does not have any field
named ‘refs_’ ./lib/refcounted.h:115:8: error: ‘refs_’ was not
declared in this scope ./lib/refcounted.h: In destructor
‘mysqlpp::RefCountedPointer::~RefCountedPointer()’:
./lib/refcounted.h:125:7: error: ‘refs_’ was not declared in this
scope ./lib/refcounted.h: In member function ‘void
mysqlpp::RefCountedPointer::swap(mysqlpp::RefCountedPointer::ThisType&)’: ./lib/refcounted.h:246:13: error: ‘refs_’ was
not declared in this scope make: *** [mysqlpp_sql_buffer.o] Error 1
I'm not really familiar with C++, so I'm not sure what the error means exactly. Any help or direction on how to get Mysql++ setup from this point would be much appreciated. Although, I admit that I'm also starting to look for alternative libraries to use.
this problem is caused because size_t depends on the inclusion of stddef namespace before it is called in the configuration (make) files.
i had the very same problem (using an amazon EC2 ubuntu 12.04 cloud server) and solved it by editing the offending file (sql_buffer.cpp located, in my case, /home/ubuntu/mysql++-3.1.0/lib) and including stddef (while also moving string namespace up):
#include <stddef.h>
#include <string.h>
#include "sql_buffer.h"
your question is answered with this correction. BUT, you might have additional problems, like i did. so i explain how i solved some subsequent problems, which you might or might not have also.
you might have to use
sudo chown username sql_buffer.cpp
to be able to edit the file, depending on how your install is setup (i am user ubuntu, for example).
i then bumped into another problem:
./ssx/genv2.cpp: In function âbool generate_ssqls2(const char*, const ParseV2*)â:
./ssx/genv2.cpp:70:28: error: âstrcmpâ was not declared in this scope
so i edited the offending file (genv2.cpp) and included string namespace
#include <string.h>
then i had ANOTHER problem with:
./libmysqlpp_ssqls2parse.a(ssqls2parse_parsev2.o): In function `Type':
/home/ubuntu/mysql++-3.1.0/./ssx/parsev2.cpp:256: undefined reference to `mysqlpp::internal::str_to_lwr
i could have edited Makefile.in but chose to simply run in command line:
sudo g++ -o test_ssqls2 test_ssqls2_ssqls2.o -lmysqlpp_ssqls2parse -L. -lmysqlclient -L/usr/lib/x86_64-linux-gnu -lmysqlpp
i then continued the make process.
that worked for me: mysql++ installed and running.
You need to install the header (dev) files, I assume one of these:
apt-cache search mysql
...
libmysqlclient-dev - MySQL database development files
libmysqlclient16 - MySQL database client library
libmysql++-dev - MySQL C++ library bindings (development)
libmysqlcppconn-dev - MySQL Connector for C++ (development files)
...
--with-mysql-lib should not be necessary because the files will be installed in the default locations.

Win7 MInGW QT MySQL program screams "cannot find -lqsqlmysqld"; where is the missing library?

I am attempting to make a qt program on Windows 7 that uses a MySQL plugin.
I have compiled both qt and the mysql plugin with no problems using my minGW 32bit compiler.
However, I keep on getting an error like this:
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/dhatt/Desktop/testdb2'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN - I"..\..\..\..\QT\qt\include\QtCore" -I"..\..\..\..\QT\qt\include\QtGui" -I"..\..\..\..\QT\qt\include\QtSql" -I"..\..\..\..\QT\qt\include" -I"..\..\..\..\MySQL\bin" -I"..\..\..\..\QT\qt\include\ActiveQt" -I"debug" -I"..\..\..\..\QT\qt\mkspecs\win32-g++" -o debug\database.o database.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\testdb2.exe debug/database.o -L"c:\QT\qt\lib" -lmingw32 -lqtmaind -L C:\MySQL\lib\opt -LC:/QT/qt/plugins/sqldrivers -lqsqlmysqld -lQtSqld4 -lQtGuid4 -lQtCored4 -LC:\MySQL\lib\opt
C:/qt/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lqsqlmysqld
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\executable.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Users/dhatt/Desktop/testdb2'
mingw32-make: *** [debug] Error 2
I apologize in advance for being very verbose of what I did, but I am doing this partly for troubleshooting, and partly so any other lost souls don't end up wasting three weeks on this particular problem. :)
Here are my specs:
Windows 7 Nokia's Open Source QT
Qt SDK for Windows (C:\Qt\2010.04\qt)
Linux MinGW Version 5.1.6 (C\Linux\MinGW)
MySQL5 with C++ files (C:\MySQL5)
If you want to know how I installed qt, just follow this site's instructions:
http://www.jiggerjuice.net/software/qt-sql-drivers.html
These other sites may hold some extra information tidbits:
http://doc.qt.nokia.com/4.6/sql-driver.html
http://www.rag.com.au/linux/qt4howto.html
http://qtnode.net/wiki?title=Qt4_on_Windows (yes, I did check with Nokia's docs!!!)
http://doc.trolltech.com/qq/qq10-windows-deployment.html
This fellow mentioned about remaking qmake, which I am not doing unless I have a good reason.
http://christopher.rasch-olsen.no/2009/04/14/qt-45-and-mysql-plugin-with-mingw-on-windows-xp/
I've already deleted the plugin cache once before, I hope I won't have to do it again...
http://doc.trolltech.com/4.2/plugins-howto.html#the-plugin-cache
http://ubuntuforums.org/showthread.php?t=1070155
If there is any confusion, between the two compilation option (creating the mysql libraries statically, or as a plugin), I chose for the plugin because it compiles quicker and I don't have to worry about licensing.
Generally, the big trouble of mysql to most people is to make a mingw compatible library. Generally, I did this with the mingw tools in ( https://olex.openlogic.com/packages/mingw-utils )...
c:\> cd MySQL\lib\opt
c:\mysql\lib\opt> reimp -d libmysql.lib
c:\mysql\lib\opt> dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a -k
I should have done it right since in my C:\MySQL\lib\opt, it has the two files:
libmysql.a
libmysql.lib
LIBMYSQL.def (not a typo)
and in the C:\MySQL\bin directory, I have:
libmySQL.bin (not a typo)
I had compiled the mysql plugin beforehand:
cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\lib\opt\libmysql.lib" mysql.pro
mingw32-make
As a result, I have in my C:\QT\qt\plugins\sqldrivers folder:
libqsqlmysql4.a
libqsqlmysqldq4.a
libqsqlodbc4.a
libqsqlodbcd4.a
qsqlmysql4.dll
qsqlmysqld4.dll
qsqlodbc4.dll
qsqlodbc4.dll
And in my C:\QT\bin folder
QtSql4.dll
QtSqld4.dll
So, I assume from this site ( http://www.qtforum.org/article/21352/how-to-compile-use-a-mysql-driver.html) that I got it right.
I didn't use the binaries of qt itself, I used the compiled qt files(also from Nokia), but reconfigured and recompiled them using mingw32-make. I had no errors. This was my configuration options for remaking qt.
-opensource
-nomake examples
-nomake demos
-no-sql-lite
-no-qt3support
-no-gif
-no-libpng
-no-libmng
-no-libtiff
-no-phonon
-no-phonon-backend
-no-multimedia
-no-audio-backend
-no-webkit
-no-script
-no-scripttools
-nodeclarative
-plugin-sql-mysql -l mysql -I C:\QT\qt\include -L C:\QT\qt\lib\opt
Here is my .pro file
LANGUAGE = C++
TEMPLATE = app
TARGET = executable
QT += core sql
QTPLUGIN += qsqlmysql
DEPENDPATH += .
INCLUDEPATH += C:\MySQL\bin
LIBS += -L C:\MySQL\lib\opt -lmysql
# Input
SOURCES += database.cpp
I installed the plugin described in here:
C:\QT\qt
My path variables are:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Python26;C:\Linux\Cygwin\bin;C:\mingw-utils-0.3\bin;C:\QT\qt\bin;C:\MySQL\bin;C:\MySQL\include;C:\QT\mingw32\bin;C:\QT\mingw\bin;C:\QT\qt\plugins\sqldrivers
The qt command prompt added a few extra though, so I did all of this in the command prompt.
Setting up a MinGW/Qt only environment...
-- QTDIR set to C:\QT\qt
-- PATH set to C:\QT\qt\bin
-- Adding C:\QT\bin to PATH
-- Adding C:\Windows\System32 to PATH
-- QMAKESPEC set to win32-g++ (mingw is my only compiler so, this is unnecessary)
Although I either did all that already, or it is redundant. I only add this for the sake of completeness.
Here is my code (database.cpp):
#include <QtSql>
#include <iostream>
using namespace std;
int main( int argc, char ** argv )
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("---.---.---.---");
db.setDatabaseName("--------");
db.setUserName("------------");
db.setPassword("------------");
if (!db.open()) cout << "Failed to connect to mysql" << endl;
else cout << "Works finally." << endl;
QSqlDatabase::removeDatabase("QMYSQL");
exit ( 0 );
}
Very simple, yes?
I went to my directory with the example code, run
mingw32-make distclean
qmake
mingw32-make
and get the error message above. I've tried building a version with the release version only (no debug), and it still shows the same message, but with "cannot find -lqsqlmysq", so it is not that.
I've tried many things, but where should I look next to solve it; maybe someone can narrow it down for me, set me on the right path, or even better, solve his annoying problem.
Also, I plan to use python bindings with my code (I need PyQT + MySQL). If the proposed solution would prevent me from doing so, let me know.
Well, I'm going to solve my own problem, again, so let's make this fun!
This is your last chance.
After this, there is no turning back.
You download the PyQT.exe, the story ends. You wake up in your bed and you believe whatever you want to believe. You modify the .pro file, you stay in wonderland. And, I show you how deep the rabbit hole goes.
I eventually gave up and downloaded the .exe, which does have MySQL support out of the box. If mysql does not work, your application is the problem, and I recommend you read this post here ( http://lists.trolltech.com/qt-interest/2006-06/thread00292-0.html ) or follow the quote below:
The issue is that you either have to
use the addLibraryPath method or
create a QCoreApplication instance
before your first call to loading a
database
Believe me, manually installing PyQT+MySQL on Windows is a pain. But if you need some out of the way plugin to get at that the executable doesn't know, you have to go down the rabbit hole further.
Here is the new and improved .pro file:
LANGUAGE = C++
TEMPLATE = app
TARGET = executable
QT += core sql
QTPLUGIN += qsqlmysql
DEPENDPATH += .
INCLUDEPATH += C:\MySQL\bin
LIBS += -L C:\MySQL\lib\opt
# Input
SOURCES += database.cpp
Turns out I did have the right path to mysql, I was just confusing it with the .pro file that I had. After redownloading qt and following the steps above again, modifying my .pro file made all the difference.
But now I had to download SIP and PyQT. I followed the docs on there. There are a few more problems. Follow the links or the directions which are left there in case the information is removed.
If your SIP make install has an error where it is looking at Unix paths (/usr/bin) instead of DOS paths (C:\QT), look at this link http://old.nabble.com/Building-SIP-on-MinGW-:-problem-at-%22make-install%22-td28909249.html#
(short version: the problem is the sh.exe in one of your other linux compilers like cygwin or msys, change the name temporarily to force the make install to use DOS path naming):
If you configure PyQT and it spits out a file error that has to do with QTCore
Google pexports and download. Go to %QTdir%/bin. Then follow instructions or link ( http://jeethurao.com/blog/?p=18 )
pexports QtCore4.dll > QtCore4.def
dlltool –dllname QtCore4.dll –def QtCore4.def –output-lib libQtCore4.a
move libQtCore4.a ..\lib
And now you know kung-fu.
P.S: I never tried this method myself. This is a different, but untested (by me) method of compiling PyQT, done up by the trolls at Trolltech:
http://www.diotavelli.net/PyQtWiki/InstallingPyQTCommercialWin