MinGW libmysql.a - the simplest HOWTO

MinGW libmysql.a - the simplest HOWTO

am 10.04.2005 16:22:59 von sebastos1

There is a simple way to get a working MySQL import library for
Mingw. The particular flavor of the library (for example
libmysqlclient.a) depends only on how you edit a .def file for Mysql
dll.

The idea is not mine; it was exhaustively described in the gcc
documentation (you will have to find it by yourselves since I have
no access to my computer at this moment).

The only thing one has to do is to write as follows:

bash# dllwrap --export-all-symbols --output-def libmysql.def
libmysql.dll --implib liblibmysql.a

or something like this - consider the exact syntax using
dllwrap/dlltool --help outputs. Of course, libmysql.dll should be
placed in the current directory. So, 'cd' or 'fsutil hardlink
create' to make the dll available.

Now you have two files: libmysql.def and liblibmysql.a. The former
file contains all the import symbols in a standard form, without any
stdcall-like @'s. The latter is the library, ready to link with your
applications. As I have tested, it connects to the server and
executes queries, what means it is working.

Since the library doesn't use stdcalls, you will have to disable
them in the mysql.h file by modifying the appropriate #ifdef's (add
something like 'defined WIN32' where necessary). Another possible
way is to compile your program with -D__CYGWIN__ ;) but I have not
tested it.

If you want to get several import libraries such as the mentioned
libmysqlclient.a, it will be necessary to edit the libmysql.def
file, erasing the symbols that don't belong to libmysqlclient, save
it as e.g. new.def and re-execute dllwrap with

--def new.def

option added.

That's all. I don't know yet how to create libmysqld.a, so don't ask
me about this. Also, don't blame me if the above method won't work -
instead, read the documentation several times as I did.

Cheers

--

sebastos1@o2.pl



--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org