Ver Mensaje Individual
  #6 (permalink)  
Antiguo 17/07/2006, 09:28
laulaurys
 
Fecha de Ingreso: junio-2005
Mensajes: 337
Antigüedad: 19 años
Puntos: 1
Hola!

agregue lo que me pasaste, me quedo asi:

#include <stdio.h>
#include <mysql/mysql.h>
int main (int argc, char *argv[]) {

MYSQL *dbase;
MYSQL *mysql;
int result = 0;

mysql_init(mysql);
dbase=mysql_init(NULL);
dbase->reconnect=1;
char *server="192.168.0.240";
char *user="root";
char *password="";
char *database="sermax";

printf("Como va?\n");

printf("Vamos a ver si nos conectamos a %s",argv[1]);

if (!mysql_real_connect(dbase, server, user, password, database, 0, NULL, 0) ) {
printf("\n\n Recuerda el uso es: %s host db user password\n\n",argv[0]);
return(-1);
} else {
printf("OK conexion establecida!!");
}


printf("Como fue?\n");

}

Compilo asi:

gcc -o Conectar-I'/usr/include/mysql' -L'/usr/lib/mysql' \
-lmysqlclient -lz -lcrypt -lnsl -lm Conectar.c

Y me tira el siguiente error:

/tmp/ccmEkw29.o(.text+0x2a): In function `main':
: undefined reference to `mysql_init'
/tmp/ccmEkw29.o(.text+0x37): In function `main':
: undefined reference to `mysql_init'
/tmp/ccmEkw29.o(.text+0xa5): In function `main':
: undefined reference to `mysql_real_connect'
collect2: ld returned 1 exit status

Lei el ejemplo que me pasaste pero es para C++, yo estoy usando C.

Gracias por tu colaboracion, espero mas ayuda! Graciass!!