digitalmars.D.learn - MySQL
- Mars (10/11) Jan 21 2012 Hello everyone.
- DNewbie (5/18) Jan 21 2012 --
- Mars (2/4) Jan 21 2012 The lib is 32 bit, just like my application.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (7/18) Jan 21 2012 Are you also including the library on the command line with -L-l? For
- Mars (6/12) Jan 21 2012 Yes, I am including it. Tried pragma and command line. And I
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (5/20) Jan 22 2012 -L is dmd's the linker flag option. Anything after that is passed to the...
- Mars (5/10) Jan 22 2012 Normally I just include the lib files in the files list (dmd
- Jesse Phillips (4/9) Jan 22 2012 No, in fact I couldn't find how to pass a library search path to
- DNewbie (4/30) Jan 22 2012 I've took a look at MySQL headers, the functions use __stdcall, but in l...
- Mars (4/6) Jan 22 2012 This means...?
- DNewbie (3/11) Jan 22 2012 You should add 'extern(Windows)', but it would not work anyway.
- Kapps (12/23) Jan 22 2012 The way I did it is
- Mars (5/6) Jan 22 2012 Oh man... that was the problem. The file I used was using
- Mike Parker (4/9) Jan 23 2012 A number of libraries on Windows use a different calling convention. Any...
- DNewbie (25/41) Jan 22 2012 You can try
Hello everyone. I've been trying to use MySQL in an application on Windows, but I always getSymbol Undefined _mysql_initI'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
Jan 21 2012
Please check whether your MySQL lib is 64 bit and your app is 32 bit. On Sat, Jan 21, 2012, at 10:38 PM, Mars wrote:Hello everyone. I've been trying to use MySQL in an application on Windows, but I always get-- DSymbol Undefined _mysql_initI'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
Jan 21 2012
On Saturday, 21 January 2012 at 23:44:12 UTC, DNewbie wrote:Please check whether your MySQL lib is 64 bit and your app is 32 bit.The lib is 32 bit, just like my application.
Jan 21 2012
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 getAre 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. AliSymbol Undefined _mysql_initI'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
Jan 21 2012
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. AliYes, 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
On 01/21/2012 06:28 PM, Mars wrote:On Sunday, 22 January 2012 at 00:50:28 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 AliAre 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. AliYes, 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 22 2012
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 AliLet me rephrase that, is this valid for OPTLINK?Unknown Option : LLIBMYSQLNormally I just include the lib files in the files list (dmd foo.d bar.lib). Mars
Jan 22 2012
On Sunday, 22 January 2012 at 12:11:58 UTC, Mars wrote:Let me rephrase that, is this valid for OPTLINK?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.Unknown Option : LLIBMYSQLNormally I just include the lib files in the files list (dmd foo.d bar.lib). Mars
Jan 22 2012
On Sun, Jan 22, 2012, at 12:11 AM, Ali =C3=87ehreli wrote:On 01/21/2012 06:28 PM, Mars wrote:=20On Sunday, 22 January 2012 at 00:50:28 UTC, Ali =C3=87ehreli wrote:=20 -L is dmd's the linker flag option. Anything after that is passed to the=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. AliYes, 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). Marslinker. So -L-l passes -l to the linker: =20 http://www.d-programming-language.org/dmd-linux.html =20 Ali =20I've took a look at MySQL headers, the functions use __stdcall, but in libm= ysql.dll exports table they are not decorated.
Jan 22 2012
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?
Jan 22 2012
On Sun, Jan 22, 2012, at 01:13 PM, Mars wrote:On Sunday, 22 January 2012 at 10:21:29 UTC, DNewbie wrote: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)?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?
Jan 22 2012
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 getSymbol Undefined _mysql_initI'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
Jan 22 2012
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
On 1/23/2012 11:29 AM, Mars wrote:On Sunday, 22 January 2012 at 23:23:23 UTC, Kapps wrote: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).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 23 2012
On Sun, Jan 22, 2012, at 11:02 PM, DNewbie wrote:On Sun, Jan 22, 2012, at 01:13 PM, Mars wrote:You can try // ----- libmysql.def --------------- LIBRARY "libmysql.dll" EXETYPE NT SUBSYSTEM WINDOWS EXPORTS _mysql_init 4=mysql_init // ---------------------------------------- // ----------- mysqltest.d ---------------- import libmysql; alias void MYSQL; int main() { MYSQL *m = libmysql.mysql_init(null); return 0; } // --------------------------------------------------- // --------------- libmysql.di ------------------- alias void MYSQL; export extern (Windows) MYSQL *mysql_init(MYSQL *); // ---------------------------------------------------- $ implib /system libmysql.lib libmysql.def $ dmd mysqltest.d libmysql.lib It works..On Sunday, 22 January 2012 at 10:21:29 UTC, DNewbie wrote: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)?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?
Jan 22 2012