DDBI and MySQL

Chris R. Miller lordSaurontheGreat at gmail.com
Fri Aug 29 20:16:22 PDT 2008


Max Samukha wrote:
> On Fri, 29 Aug 2008 01:07:35 -0700, "Chris R. Miller"
> <lordSaurontheGreat at gmail.com> wrote:
> 
>> Don wrote:
>>> Chris R. Miller wrote:
>>>> I've been working to attempt to get DDBI to work with MySQL.
>>>> Unfortunately I'm stuck with the Windows platform for lack of the
>>>> impetus and know-how to get the compiler working elsewhere.
>>>>
>>>> I use a slightly modified version of DDBI to get SQLite to work.  I
>>>> don't think that would disrupt the workings of MySQL.
>>>>
>>>> Once I found the correct library file to use (buried in a large download
>>>> of MySQL - the server, which was annoying) I found that the whole
>>>> she-bang didn't work at all.  It was all tied to a strange external
>>>> declaration in imp_win.d, which apparently decided that on Windows the
>>>> MySQL support is provided by extern(Windows) instead of extern(C).
>>> I hope you changed that to extern(System) ? It sounds like an old MySQL
>>> file.
>> No, it all links properly with extern(C).
>>
> 
> MySQL API uses stdcall calling convention on Windows so
> extern(Windows) in imp_win.d is correct. Here is an import library for
> libmysql.dll that works for me
> http://d-coding.com/downloads/libmysql.lib

Changed it back to extern(Windows) and still no joy.  I also tried using
your supplied library file, but nothing worked, either.

As soon as I changed it from extern(C) I was greeted by these errors though:

dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_init at 4
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_real_connect at 32
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_errno at 4
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_error at 4
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined
_D3dbi5mysql10MysqlError17specificToGeneralFkZE3dbi9
ErrorCode9ErrorCode
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_close at 4
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_real_query at 12
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_store_result at 4
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_insert_id at 4
dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined _mysql_get_client_version at 0
dsss_objs\D\dbi-mysql-MysqlResult.obj(dbi-mysql-MysqlResult)
 Error 42: Symbol Undefined _mysql_fetch_row at 4
dsss_objs\D\dbi-mysql-MysqlResult.obj(dbi-mysql-MysqlResult)
 Error 42: Symbol Undefined _mysql_fetch_lengths at 4
dsss_objs\D\dbi-mysql-MysqlResult.obj(dbi-mysql-MysqlResult)
 Error 42: Symbol Undefined _mysql_free_result at 4
dsss_objs\D\dbi-mysql-MysqlResult.obj(dbi-mysql-MysqlResult)
 Error 42: Symbol Undefined _mysql_num_fields at 4
dsss_objs\D\dbi-mysql-MysqlResult.obj(dbi-mysql-MysqlResult)
 Error 42: Symbol Undefined _mysql_fetch_fields at 4

I'm not an expert at all, but I think that's because it can't discover
the functions to link against.  If I change it back to extern(C) I get this:

dsss_objs\D\dbi-mysql-MysqlDatabase.obj(dbi-mysql-MysqlDatabase)
 Error 42: Symbol Undefined
_D3dbi5mysql10MysqlError17specificToGeneralFkZE3dbi9
ErrorCode9ErrorCode

Which is a regression from what I had when I had changed it to ignore
imp_win.d and to use imp.d instead.

So I'm thoroughly confused.  I suspect that I *almost* had it working
with the imp.d save for the cast problems (which could be a compiler bug
- if it's not, then there's a lot I'm going to be learning about
pointers in my upcoming CS 102 class!)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20080829/d8e10af6/attachment.pgp>


More information about the Digitalmars-d mailing list