www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - MySQL

reply "Mars" <- -.-> writes:
Hello everyone.
I've been trying to use MySQL in an application on Windows, but I 
always get
 Symbol Undefined _mysql_init

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
Jan 21 2012
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/21/2012 01: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

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

Are you also including the library on the command line with -L-l? For example, for ncurses: dmd ... -L-lncurses ... And if needed, also -L-L to specify the location of library files for the linker. Ali
Jan 21 2012
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/21/2012 06:28 PM, Mars wrote:
 On Sunday, 22 January 2012 at 00:50:28 UTC, Ali Çehreli wrote:
 Are you also including the library on the command line with -L-l? For
 example, for ncurses:

 dmd ... -L-lncurses ...

 And if needed, also -L-L to specify the location of library files for
 the linker.

 Ali

Yes, I am including it. Tried pragma and command line. And I don't get a message that the lib couldn't be found. What exactly is -L-l supposed to do? Is this valid in DMD 2.057? I get an error with it (Unknown Option). Mars

-L is dmd's the linker flag option. Anything after that is passed to the linker. So -L-l passes -l to the linker: http://www.d-programming-language.org/dmd-linux.html Ali
Jan 22 2012
prev sibling next sibling parent "Mars" <- -.-> writes:
On Sunday, 22 January 2012 at 00:50:28 UTC, Ali Çehreli wrote:
 Are you also including the library on the command line with 
 -L-l? For example, for ncurses:

  dmd ... -L-lncurses ...

 And if needed, also -L-L to specify the location of library 
 files for the linker.

 Ali

Yes, I am including it. Tried pragma and command line. And I don't get a message that the lib couldn't be found. What exactly is -L-l supposed to do? Is this valid in DMD 2.057? I get an error with it (Unknown Option). Mars
Jan 21 2012
prev sibling next sibling parent "Mars" <- -.-> writes:
On Sunday, 22 January 2012 at 08:11:21 UTC, Ali Çehreli wrote:
 -L is dmd's the linker flag option. Anything after that is 
 passed to the linker. So -L-l passes -l to the linker:

  http://www.d-programming-language.org/dmd-linux.html

 Ali

Let me rephrase that, is this valid for OPTLINK?
Unknown Option : LLIBMYSQL

foo.d bar.lib). Mars
Jan 22 2012
prev sibling next sibling parent "Jesse Phillips" <jessekphillips+D gmail.com> writes:
On Sunday, 22 January 2012 at 12:11:58 UTC, Mars wrote:
 Let me rephrase that, is this valid for OPTLINK?
Unknown Option : LLIBMYSQL

foo.d bar.lib). Mars

No, in fact I couldn't find how to pass a library search path to optlink. It can be added to the sc.ini file, but I couldn't find a command line option. -l is an ld flag.
Jan 22 2012
prev sibling next sibling parent reply Kapps <Kapps NotValidEmail.com> writes:
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

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

Jan 22 2012
parent Mike Parker <aldacron gmail.com> writes:
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).
Jan 23 2012
prev sibling parent "Mars" <- -.-> writes:
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
Jan 22 2012