Beiträge getaggt mit mysql++
mingw, mysql und mein Weg in die Hölle! – Tutorial
11. Jun
Ein Tutorial über das Kompilieren eines C++ Connectors für MySQL in Windows per mingw. Da evtl. auch internationales Publikum daran Interesse hat wird dieser Eintrag ausnahmsweise in Englisch verfasst.
Since I wasted several hours today by compiling a c++ connector for mysql and I couldnt find a good/working tutorial on the web (all I have found seem to be outdated/not working..) I will write one myself.
What do you need?
A working compiler (mingw32 in my case)
But since the automatic downloader seems unsupported I found a nice alternative: http://tdm-gcc.tdragon.net/ this mingw port will be needed when I want to compile Ogre3D anyways so I gave it a try. Downloaded the bundled installer and installed it. (NOT to C:/mingw/ as suggested, I installed it to E:/mingw32). But then you have to add to your windows PATH variable: E:/mingw32/bin;E:/mingw32/libexec/gcc/mingw32/4.5.0 otherwise some tools can not be found.
MYSQL DEV community server (http://dev.mysql.com/downloads/mysql/)
I downloaded the mysql-noinstall-5.1.47-win32.zip version, unzipped it and placed it under E:/libs/mysql
MYSQL++ Library (http://tangentsoft.net/mysql++/)
I couldnt compile the Mysql c++ connector. I had always strange errors and broken referenzes, so we will stick with this lib. I extracted it an placed it under E:/libs/mysql++
Now the fun begins… the ppl from Mysql++ seem not be able to write a working tutorial I had to get information from the readme files and the net but here it goes:
Compiling
- Go to E:/libs/mysql++ and open Makefile.mingw add:
MYSQL_DIR := "E:/libs/mysql"
# Standard flags for C++
CXXFLAGS ?= -I$(MYSQL_DIR)/include -I"E:/libs/mysql++/include"
# Standard preprocessor flags (common for CC and CXX)
CPPFLAGS ?=
# Standard linker flags
LDFLAGS ?= -L"$(MYSQL_DIR)/lib/opt" -L"E:/libs/mysql++/lib" - Look in the Makefile for lines when they link the .exe which have as linking libraries: …. $(LDFLAGS) -lmysqlclient -lmysqlpp -lmysqlpp_ssqls2parse THIS IS WRONG Its written somewhere in their online doc that the linker links from RIGHT to LEFT so on the right side should stand the most general library (which is mysqlclient.lib) otherwise there will be reference errors. So correct ALL lines in the makefile and put -lmysqlclient to the right followed by -lmysqlpp und FINALY -lmysqlpp_ssqls2parse. It should look like: -lmysqlpp_ssqls2parse -lmysqlpp -lmysqlclient
This will occur in a few lines which you have to find an correct. - As described in README-MinGW.txt do the following (by exchanging the paths according to yours of course)
cd E:\libs\mysql\lib\opt
dlltool -k -d E:\libs\mysql++\libmysqlclient.def -l libmysqlclient.a
This will produce a .a file which is recognized by mingw since it has a different bytecode then MS Visual compiler which was used to compile the MySQL Dev files. - Open a command prompt go to E:\libs\mysql++ and write: mingw32-make -f Makefile.mingw
- And be happy! It should do a working compile! Took me over 5 hours to get it working…
EDIT: I got a message from a reader how he managed to compile the mysql-connector-c und mysql-connector-c++ . I didn’t test it though but it looks promising, so if you like and need the official connector feel free to give it a try. =)
The solution ist from Martin Trautmann and can be found in the mysql forum: http://forums.mysql.com/read.php?117,425191,425191#msg-425191 Thanks for the hint!