January 22, 2012Re: MySQL
On Sun, Jan 22, 2012, at 01:13 PM, Mars wrote: > On Sunday, 22 January 2012 at 10:21:29 UTC, DNewbie wrote: > > I've took a look at MySQL headers, the functions use stdcall, but in libmysql.dll exports table they are not decorated. > > This means...? > Shouldn't it at least compile, if they are listed in the def > file, coming from the lib? > You should add 'extern(Windows)', but it would not work anyway. Can someone confirm the oplink does not handle this type of module (undecorated stdcall functions)?
January 22, 2012Re: MySQL
The way I did it is 1) Download C connector from mysql's website, 6.0.2 is version headers were made for. Remember you'll need the 32-bit one if you're using DMD on Windows. 2) Create the binding functions using extern(System). 3) For Windows, use 'coffimplib libmysql.dll libmysql.lib', and build with "PathToFile/libmysql.lib". Example: 'dmd test.d libmysql.lib' 3b) For Linux, just link to libmysqlclient. a with -L"libmysqlclient.a" or by just passing path. 4) Make sure that libmysql.dll (for Windows) is in the application folder otherwise you'll get errors when trying to run. On 21/01/2012 3:38 PM, Mars wrote: > Hello everyone. > I've been trying to use MySQL in an application on Windows, but I always > get >> Symbol Undefined _mysql_init > I've put the lib in the correct folder, so I don't know what the problem > might be. I've tried several libs, and tried to compile it myself > (always converted using coffimplib), but it fails, no matter what. I've > also tried to make a def file out of the lib, and the functions are > definitly listed as exports there. > Any idea what I might doing wrong? > > Mars
January 23, 2012Re: MySQL
Posted in reply to Kapps
On Sunday, 22 January 2012 at 23:23:23 UTC, Kapps wrote: > 2) Create the binding functions using extern(System). Oh man... that was the problem. The file I used was using extern(C). Thought that was okay, it's a C lib after all. Thank you! Mars
January 24, 2012Re: MySQL
On 1/23/2012 11:29 AM, Mars wrote: > On Sunday, 22 January 2012 at 23:23:23 UTC, Kapps wrote: >> 2) Create the binding functions using extern(System). > > Oh man... that was the problem. The file I used was using extern(C). > Thought that was okay, it's a C lib after all. Thank you! > > Mars A number of libraries on Windows use a different calling convention. Any functions declared WINAPI or PASCAL in the C headers need to be declared either extern(Windows) or, if cross-platform, extern(System).
Copyright © 1999-2016 by the D Language Foundation