Re: Problem compiling
[email protected] Tue, 14 Nov 2006 13:24:00 +0100
| Newsgroups | gmane.comp.lib.libwww |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. --=_1b1c1sv9sz1c Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable hi, it's true, i used webbot with mysql and i needed to do the same that =20 you explained. I'm sending you the correct file. I use ubuntu 6.10 and webbot works =20 fine. As "configure", I used: ./configure ?with-mysql=3D/usr/lib/libmysqlclient.a Good luck! Quoting OTR Comm <[email protected]>: > > hello, > > John Coppens wrote: >> >> Hello people. >> >> I've tried to compile libwww with mysql support and had a few =20 >> problems. (without >> mysql support installation went fine) >> >> Configure was done with --with-mysql=3D/opt/mysql >> (lib and include are below /opt/mysql) >> >> the configure process gave a first indication of problems: >> >> checking for /opt/mysql/... -L/opt -lmysql >> >> Which isn't correct, I think. I believe it should be =20 >> -L/opt/mysql/lib -lmysql >> >> Compilation stopped: >> >> /bin/sh ../../libtool --mode=3Dcompile gcc -DHAVE_CONFIG_H -I. -I. =20 >> -I../.. -I/usr/local/include -I../../modules/md5 =20 >> -I../../modules/expat/xmlparse =20 >> -DW3C_ICONS=3D\"/usr/local/share/w3c-libwww\" -g -O2 -Wall -c HTSQL.c >> .../../libtool: line 732: test: =3D: unary operator expected >> rm -f .libs/HTSQL.lo >> gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I/usr/local/include =20 >> -I../../modules/md5 -I../../modules/expat/xmlparse =20 >> -DW3C_ICONS=3D\"/usr/local/share/w3c-libwww\" -g -O2 -Wall -c HTSQL.c =20 >> -fPIC -DPIC -o .libs/HTSQL.lo >> In file included from HTSQL.c:19: >> HTSQL.h:34:25: mysql/mysql.h: No such file or directory >> In file included from HTSQL.c:19: >> HTSQL.h:97: error: syntax error before '*' token >> HTSQL.h:97: warning: type defaults to `int' in declaration of =20 >> `HTSQL_getMysql' >> >> mysql/mysql.h does exist, under /opt/mysql/include >> >> I'm no expert programmer, but I did compile a few apps (including =20 >> some of my own) >> with mysql without problems... > > i am using w3c-libwww-5.4.0, what are you using? > > in w3c-libwww-5.4.0, HTSQL.c, HTSQL.h, and HTSQLLog.c are incorrect. > they need to be hacked! > > if you look in Library/src off the base directory of your distribution > of w3c-libwww, you will find HTSQL.c, HTSQL.h, and HTSQLLog.c > > check to see if HTSQL.c uses mysql_connect or mysql_real_connect, if > 'mysql_connect', then you need to hack the code because 'mysql_connect' > has been eliminated from mysql. they use 'mysql_real_connect' now, and > the syntax is different. if you need help, write me directly > ([email protected]), and i will guide you through how to get > w3c-libwww compiled with mysql support. > > i use redhat 7.3, fedora core 4, and fedora core 5 systems and DO NOT > install mysql at system build or with rpms or yum or apt-get. i always > install the mysql tarball. i use mysql-4.1.15. > > i build mysql with: > > ../configure --prefix=3D/usr/local/mysql --with-mysqld-user=3Dmysql > --with-unix-socket-path=3D/tmp/mysql.sock > > so mysql gets installed in /usr/local/mysql. NOTE: adduser mysql before > so the '--with-mysqld-user=3Dmysql' switch makes sense :) > > then to get libww installed with mysql support, i use: > > ../configure --with-gnu-ld > --with-mysql=3D/usr/local/mysql/lib/mysql/libmysqlclient.a > > works like a charm on several systems after i hacked the code mentioned > above! > > > regards, > murrah boswell > > > --=_1b1c1sv9sz1c Content-Type: text/x-csrc; charset=UTF-8; name="HTSQL.c" Content-Disposition: attachment; filename="HTSQL.c" Content-Transfer-Encoding: quoted-printable /*=09=09=09=09=09=09=09=09 HTSQL.c **=09MYSQL INTERFACE MODULE ** **=09(c) COPYRIGHT MIT 1995. **=09Please first read the full copyright statement in the file COPYRIGH. **=09@(#) $Id: HTSQL.c,v 2.3 2005/07/25 22:05:36 vbancrof Exp $ ** **=09This module interacts with the MYSQL C client library to perform **=09SQL operations. It is not intended as a complete SQL API but handles **=09most of the typical error situations talking to an SQL server so that **=09the caller doesn't have to think about it. ** ** History: ** =0923 Apr 98=09Henrik Frystyk, [email protected] */ /* Library include files */ #include "WWWLib.h" #include "HTSQL.h"=09=09=09=09=09 /* Implemented here */ #include <mysql/mysql.h> #include <mysql/errmsg.h> /* updates for to remove deprecated mysql functions */ #define mysql_connect(m,h,u,p) mysql_real_connect((m),(h),(u),(p),NULL,0,NUL= L,0)=20 /* mysql documentation indicates that database names have a maximun of 65 ch= aracters */ #define CREATE_DB_BUFFER_SIZE 128 #define CREATE_DB_QUERY_FORMAT "create database %s" struct _HTSQL { MYSQL=09=09server; MYSQL *=09=09psvr; const char *=09host; const char *=09user; const char *=09password;=09=09/* @@@ Should be scambled! @@@ */ const char *=09db; }; /* -------------------------------------------------------------------------= */ PRIVATE int sql_datetimestr (char ** ptr, time_t t) { int length =3D -1; if (t > 0 && *ptr) { #if defined(HT_REENTRANT) || defined(SOLARIS) =09struct tm gmt; =09struct * pgmt =3D gmtime_r(&t, &gmt); #else =09struct tm *pgmt =3D gmtime(&t); #endif /* SOLARIS || HT_REENTRANT */ #ifdef HAVE_STRFTIME =09length =3D strftime(*ptr, 40, "\'%Y-%m-%d %H:%M:%S\'", pgmt); #else =09length =3D sprintf(*ptr, "\'%04d-%02d-%02d %02d:%02d:%02d\'", =09=09pgmt->tm_year + 1900, =09=09pgmt->tm_mon + 1, =09=09pgmt->tm_wday + 1, =09=09pgmt->tm_hour, =09=09pgmt->tm_min, =09=09pgmt->tm_sec); #endif /* HAVE_STRFTIME */ =09/* Remove the trailing zero */ =09*ptr =3D *ptr + strlen(*ptr); =09**ptr++ =3D ' '; } return length; } PUBLIC char * HTSQL_printf (char * buf, int length, char * fmt, ...) { va_list pArgs; char * p=3Dfmt; char * q=3Dbuf; char * cpar; unsigned upar; long lpar; time_t tpar; va_start(pArgs, fmt); while (*p && length>0) { =09if (*p =3D=3D '%') { =09 switch (*++p) { =09 case 's': =09=09if ((cpar =3D va_arg(pArgs, char *)) !=3D NULL) { =09=09 char * cp =3D cpar; =09=09 while ((*q++ =3D *cp++) && length-->0); q--; =09=09} else { =09=09 *q++=3D'n'; *q++=3D'u'; *q++=3D'l'; *q++=3D'l'; =09=09 length -=3D 4; =09=09} =09=09break; =09 case 'S': =09=09if ((cpar =3D va_arg(pArgs, char *)) !=3D NULL) { =09=09 char * cp =3D cpar; =09=09 *q++=3D'\''; =09=09 mysql_escape_string(q, cp, strlen(cp)); =09=09 while (*q) q++, length--; =09=09 *q++=3D'\''; =09=09} else { =09=09 *q++=3D'n'; *q++=3D'u'; *q++=3D'l'; *q++=3D'l'; =09=09 length -=3D 4; =09=09} =09=09break; =09 case 'T': =09=09if ((tpar =3D va_arg(pArgs, time_t)) > 0) { =09=09 length -=3D sql_datetimestr(&q, tpar); =09=09} else { =09=09 *q++=3D'n'; *q++=3D'u'; *q++=3D'l'; *q++=3D'l'; =09=09 length -=3D 4; =09=09} =09=09break; =09 case 'u': =09=09if ((upar =3D va_arg(pArgs, unsigned int)) >=3D 0) { =09=09 char num[32]; =09=09 char * nptr =3D num; =09=09 int i; =09=09 do { =09=09=09i =3D upar % 10; =09=09=09*nptr++ =3D i+'0'; =09=09=09upar /=3D 10; =09=09 } while (upar > 0); =09=09 while (nptr > num && length>0) *q++=3D*--nptr, length--; =09=09} else { =09=09 *q++=3D'0'; =09=09 length--; =09=09} =09=09break; =09 case 'l': =09=09if ((lpar =3D va_arg(pArgs, unsigned long)) >=3D 0) { =09=09 char num[32]; =09=09 char * nptr =3D num; =09=09 int i; =09=09 do { =09=09=09i =3D lpar % 10; =09=09=09*nptr++ =3D i+'0'; =09=09=09lpar /=3D 10; =09=09 } while (lpar > 0); =09=09 while (nptr > num && length>0) *q++=3D*--nptr, length--; =09=09} else { =09=09 *q++=3D'0'; =09=09 length--; =09=09} =09=09break; =09 default: =09=09*q++=3D*p++; =09=09length--; =09 } =09 p++; =09} else { =09 *q++=3D*p++; =09 length--; =09} } *q =3D '\0'; va_end(pArgs); return buf; } PUBLIC HTSQL * HTSQL_new (const char * host, =09=09=09 const char * user, const char * pw, =09=09=09 int flags) { HTSQL * me =3D NULL; if (!host || !user || !pw) { =09HTTRACE(SQL_TRACE, "SQL new..... Missing host, user, or password\n"); =09return NULL; } if ((me =3D (HTSQL *) HT_CALLOC(1, sizeof(HTSQL))) =3D=3D NULL) HT_OUTOFMEM("HTSQL_new"); me->host =3D host; me->user =3D user; me->password =3D pw;=09=09/* @@@ scramble!!! @@@ */ return me; } PUBLIC BOOL HTSQL_delete (HTSQL * me) { if (me) { =09if (me->psvr) HTSQL_close(me); =09HT_FREE(me); =09return YES; } return NO; } PUBLIC BOOL HTSQL_connect (HTSQL * me) { if (me && me->host) { =09HTTRACE(SQL_TRACE, "SQL connect. Open a link to server `%s\'\n" _ me->hos= t); =09if(mysql_init(&me->server)=3D=3DNULL) =09 { =09 printf("\neiiii"); =09 return 1; =09 } =09 //=09char* as =3D malloc(sizeof(mysql_get_client_info())); //=09as =3D mysql_get_client_info(); //=09printf(as); =09me->psvr =3D mysql_real_connect(&(me->server), me->host,me->user, me->pas= sword,NULL,0,NULL,0); =09=09=09=09 // me->user ? me->user : "", =09=09=09=09 //me->password ? me->password : ""); =09/*=09if(!mysql_real_connect(&(me->server), me->host,me->user, me->passwor= d,NULL,0,NULL,0)){ =09 =20 =09 fprintf(stderr, "Failed to connect to database: Error: %s\n", =09=09 mysql_error(&(me->server))); =09=09 }*/ =09 =09if (me->psvr =3D=3D NULL) { =09 // printf("ha fallat"); =09 HTTRACE(SQL_TRACE, "SQL connect. `%s\' errno %d\n" _=20 =09=09 mysql_error(&me->server) _ mysql_errno(&me->server)); =09 return NO; =09} =09printf("ei"); =09return YES; } return NO; } PUBLIC MYSQL * HTSQL_getMysql (HTSQL * me) { return me ? me->psvr : NULL; } PUBLIC BOOL HTSQL_close (HTSQL * me) { if (me && me->psvr) { =09HTTRACE(SQL_TRACE, "SQL close... Link to host `%s\'\n" _ me->host); =09mysql_close(me->psvr); =09me->psvr =3D NULL; =09me->db =3D NULL; =09return YES; } return NO; } PUBLIC BOOL HTSQL_version (HTSQL *=09=09me, =09=09=09 char **=09=09server, =09=09=09 unsigned int * =09protocol_version, =09=09=09 char **=09=09server_version, =09=09=09 char **=09=09client_version) { if (me && me->psvr) { =09if (*server) *server =3D mysql_get_server_info(me->psvr); =09if (protocol_version) *protocol_version =3D mysql_get_proto_info(me->psvr= ); =09if (*server_version) *server_version =3D mysql_get_server_info(me->psvr); =09if (*client_version) *client_version =3D mysql_get_client_info(); =09return YES; } return NO; } PUBLIC BOOL HTSQL_selectDB (HTSQL * me, const char * db) { BOOL created =3D NO; if (me && me->psvr && db) { =09HTTRACE(SQL_TRACE, "SQL select.. Database `%s\'\n" _ db); =09me->db =3D NULL; =09if (mysql_select_db(me->psvr, db) < 0) { =09 int err =3D mysql_errno(me->psvr); =09 HTTRACE(SQL_TRACE, "SQL select.. `%s\', errno %d\n" _=20 =09=09=09=09 mysql_error(me->psvr) _ err); =09 /* If the database couldn't be found then create a new one */ =09 if (err =3D=3D 1049) { =09 char CREATE_DB_BUFFER[CREATE_DB_BUFFER_SIZE]; =09 snprintf( CREATE_DB_BUFFER,=20 =09=09=09(size_t)CREATE_DB_BUFFER_SIZE, =09=09=09CREATE_DB_QUERY_FORMAT, =09=09=09db ); =09=09if (mysql_query(me->psvr, CREATE_DB_BUFFER) < 0) { =09=09 HTTRACE(SQL_TRACE, "SQL error... `%s\', errno %d\n" _=20 =09=09=09=09=09 mysql_error(me->psvr) _ err); =09=09 return NO; =09=09} =09=09created =3D YES; =09 } else =09=09return NO; =09} =09if (created) { =09 if (mysql_select_db(me->psvr, db) < 0) { =09=09int err =3D mysql_errno(me->psvr); =09=09HTTRACE(SQL_TRACE, "SQL select.. `%s\', errno %d\n" _=20 =09=09=09=09 mysql_error(me->psvr) _ err); =09=09return NO; =09 } =09} =09/* The database is now up and running */ =09me->db =3D db; =09return YES; }=20 return NO; } PUBLIC BOOL HTSQL_query (HTSQL * me, const char * query) { HTTRACE(SQL_TRACE, "SQL query... `%s\'\n" _ query ? query : "<null>"); if (me && me->psvr && query) { =09if (mysql_query(me->psvr, query) < 0) { =09 int status =3D mysql_errno(me->psvr); =09 HTTRACE(SQL_TRACE, "SQL query... `%s\' on query `%s\' with errno %d\n= " _=20 =09=09=09mysql_error(me->psvr) _ query _ status); =09 /* Check to see if we should try and reconnect */ =09 if (status=3D=3DCR_SERVER_GONE_ERROR || status=3D=3DCR_SERVER_LOST) { =09=09if (HTSQL_connect(me)=3D=3DNO || HTSQL_selectDB(me, me->db)=3D=3DNO) =09=09 return NO; =09=09return (mysql_query(me->psvr, query) =3D=3D 0); =09 } =09 return NO; =09} =09return YES; } return NO; } PUBLIC int HTSQL_getLastInsertId (HTSQL * me) { return (me && me->psvr) ? mysql_insert_id(me->psvr) : -1; } PUBLIC int HTSQL_GetAffectedRows (HTSQL * me) { return (me && me->psvr) ? mysql_affected_rows(me->psvr) : -1;=20 } =20 PUBLIC MYSQL_RES * HTSQL_storeResult (HTSQL * me) { MYSQL_RES * result =3D NULL; if (me && me->psvr) { =09if ((result =3D mysql_store_result(me->psvr)) =3D=3D NULL) { =09 int status =3D mysql_errno(me->psvr); =09 HTTRACE(SQL_TRACE, "SQL store... `%s\' with errno %d\n" _=20 =09=09=09mysql_error(me->psvr) _ status); =09} } return result; } PUBLIC BOOL HTSQL_freeResult (MYSQL_RES * me) { if (me) { =09mysql_free_result(me); =09return YES; } return NO; } --=_1b1c1sv9sz1c--