[Dev-C++] Trying to link libmysqld.lib (THE SOLUTION!!!)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Josep S. <sub...@ar...> - 2004-03-08 17:44:26
|
>>The compiler(linker) complains that >>it can't fund function xxxx@xx (e.g. I use mysql_close(), compilation ends in error like "can't find >>function mysql_close@4") IT WORKS NOW!! Yes, the problem was that the programmes "pexports" (see email from Muxas) or "impdef" generate a def file where the functions of the DLL are NOT defined in the STDCALL way (i.e. with @number after the function). Lukily, the VisualC++ version comes with a .exp file which is the equivalent for the .def file that we need in order to genarate libmysqld.a for the Dev-C++. So with a bit of copy and paste, I took the function definitions (with @number at the end) from the .exp file and manually generated a .def file that looks like this: LIBRARY LIBMYSQLD DESCRIPTION 'MySQL 4.0 Embedded Server Library' VERSION 4.0 EXPORTS myodbc_remove_escape@8 mysql_affected_rows@4 mysql_change_user@16 mysql_character_set_name@4 mysql_close@4 mysql_connect@16 ... After you have this STDCALL compliant .def file you have only to run the dlltool utility (to be found in the bin folder of mingw) with the same parameters that Muxas described (I also used the --dllname flag [see below...] and don't forget the --kill-at flag!): dlltool --input-def libmysqld.def --dllname libmysqld.dll --output-lib libmysqld.a --kill-at The generated libmysqld.a COMPILES WITH Dev-C++ without problem! I've put both the original VisualC++ project and the Dev-C++ (including the working libmysqld.a) files for DOWNLOAD on my website, http://www.subirana.de/mysql.zip so you can try if you want. Just one warning: Although now Dev-C++ compiles and links without problems thanks to the new library libmysqld.a, when you run the generated exe, it will fail to do anything (both with VisualC++ and Dev-C++): at the first invocation of a mysql function the programme ends!... This is probably due to the need to link other libraries to your programme in order to use mysql as an EMBEDDED SERVER within your c++ programme instead of having to start mysql independently (as a separate service) before you can use it with your c++ application. I HAVE STILL TO READ ABOUT and RESEARCH this issue deeper... BTW, Yeoh wrote: >>I believe it was Kip Warner who created a DevPak for MySQL. :-) >>And it can be downloaded from Dev-C++ via Tools -> Check for >>Updates/Packages. I wonder if that DevPak also supports EMBEDDED mysql! Anyway it's sure worth a try... Thanks to all for your help! Josep -----Ursprungliche Nachricht----- Von: Vetrov Maxim [mailto:mu...@ma...] Gesendet: Montag, 8. Marz 2004 13:07 An: Josep Subirana Betreff: [Dev-C++] Trying to link libmysqld.lib (Update) Hi, I usually use next procedure to get library (.a) from libmysqld.dll: (1) pexports libmysqld.dll > libmysqld.def (2) dlltool --kill-at --input-def libmysqld.def --output-lib libmysqld.a then add the library to linker options in Dev-C++ (Project options->Parameters->Linker->Add Library or Object). That's it! The only problem that I do not know how long the func parameters of the libmysql are in terms of bytes and I do not know how to extract this information from the dll. But I found that I can determine it when I compile my code with mysql function calls. The compiler(linker) complains that it can't fund function xxxx@xx (e.g. I use mysql_close(), compilation ends in error like "can't find function mysql_close@4"), so I usually take the "at" and the following number (it's length in bytes of the func parameters) an manually add it to corresponding line in .def file, then recreate the library file (.a). Hope that I help. If you find a method to automatically get parameters length in .def file - can you share it? Best wishes, Muxas |