Page 1 of 1

Using libmysql.dll via "loadLibrary()"

Posted: Fri Jul 25, 2008 12:14 pm
by JC
Dear Antonio and friends of forum!

I have tried to connect into a mysql server calling the functions of libmysq.dll with loadLib32() function.

The function mysql_init() for prepare the threads and environment to connect on the database server is running perfectly! I get a code handle for this!

But, some functions like mysql_real_connect() and others... they are not running correctly.

The fivewin, at runtime, crashing with a GPF error!

Bellow, I describe my code... Please, help me!

Code: Select all

# include "Fivewin.ch"

STATIC cMySqlLib32
STATIC hHandleConexao

// ------------
FUNCTION main()
// ------------

cMySqlLib32 := loadLib32( "libmysql.dll" )

hHandleConexao := mysql_init()

IF !mysql_real_connect( hHandleConexao, "127.0.0.1", "root", "mysql", NIL, 0, NIL )
   ? "Not connected!"
ELSE
   ? "Connected!"
ENDIF

mysql_close( hHandleConexao )

RETURN( NIL )


*** *************************************** ****
*** Declaration of funciotns at libmysq.dll ****
*** *************************************** ****
DLL32 STATIC FUNCTION mysql_init( mysql AS LPSTR ) AS LONG PASCAL FROM "mysql_init" LIB cMySqlLib32
DLL32 STATIC FUNCTION mysql_close( mysql AS LPSTR ) AS LONG PASCAL FROM "mysql_close" LIB cMySqlLib32

DLL32 STATIC FUNCTION mysql_real_connect( mysql AS LPSTR, ;
                                          host AS LPSTR, ;
                                          user AS LPSTR, ;
                                          passwd AS LPSTR, ;
                                          db AS LPSTR, ;
                                          port AS LPSTR, ;
                                          unix_socket AS LPSTR, ;
                                          client_flag AS LPSTR ) AS BOOL PASCAL FROM "mysql_real_connect" LIB cMySqlLib32

Posted: Fri Jul 25, 2008 6:18 pm
by JC
Nobody?

Posted: Sat Jul 26, 2008 12:48 am
by ShumingWang
JC,
Pls import libmysql.lib from libmysql.dll ,link libmysql.lib,mysql.lib (tmysql.prg,mysql.c,mysql.ch,mysql server 5.0/include ) into your app, you can directly use tmysql.prg .
Regards!
Shuming Wang

Posted: Sat Jul 26, 2008 4:50 am
by Antonio Linares
Please use LoadLibrary() and DLL FUNCTION ...

LoadLib32() and DLL32 FUNCTION are for 16 bits apps.

Posted: Mon Jul 28, 2008 11:14 am
by JC
ShumingWang wrote:JC,
Pls import libmysql.lib from libmysql.dll ,link libmysql.lib,mysql.lib (tmysql.prg,mysql.c,mysql.ch,mysql server 5.0/include ) into your app, you can directly use tmysql.prg .
Regards!
Shuming Wang
Shuming, I tried to use the libmysql.lib but, returns the following error:

Code: Select all

Error: 'H:\FWH8.06\FWH\SAMPLES\LIBMYSQL.LIB' contains invalid OMF record, type 0
x21 (possibly COFF)

Posted: Mon Jul 28, 2008 11:15 am
by JC
Antonio Linares wrote:Please use LoadLibrary() and DLL FUNCTION ...

LoadLib32() and DLL32 FUNCTION are for 16 bits apps.
Dear Linares, thank for trip.... I will use!

Posted: Tue Jul 29, 2008 2:17 am
by ShumingWang
JC,
Genarate libmysql.lib from libmysql.dll, libmysql.dlls are different among different Mysql versions.
\bcc55\bin\implib.exe libmysql.lib libmysql.dll
Regards!
Shuming Wang

Posted: Tue Jul 29, 2008 4:42 pm
by JC
ShumingWang wrote:JC,
Genarate libmysql.lib from libmysql.dll, libmysql.dlls are different among different Mysql versions.
\bcc55\bin\implib.exe libmysql.lib libmysql.dll
Regards!
Shuming Wang
Thanks Shuming... it's work! I will try now!

Posted: Tue Jul 29, 2008 4:55 pm
by JC
Shuming, it's work now with libmysql.lib via implib.exe

But, the function mysql_real_connect() still not recognized :(

I will go work better! Thanks for all!