Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/06/2010, 07:09
janoxio
 
Fecha de Ingreso: junio-2010
Mensajes: 2
Antigüedad: 13 años, 10 meses
Puntos: 0
Ayuda MySQL (undefined reference to `mysql_init')

Amigos, tengo este codigo...


///////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <stdio.h>
#include <mysql/mysql.h>
#include <string>
#include <cstring>
#include <cstdlib>

sing namespace std;

int main(int argc, char **argv)
{

/*CONEXION A BASE DE DATOS*/
MYSQL mysql;
if(mysql_init(&mysql)==NULL)
{
printf("\nFailed to initate MySQL connection");
}

if (!mysql_real_connect(&mysql,"localhost","root","ba se","prueba_c",0,NULL,0))
{
printf( "Failed to connect to MySQL: Error: %s\n", mysql_error(&mysql));
}


printf("Logged on to database sucessfully\n");
mysql_close(&mysql);

return 0;
}

///////////////////////////////////////////////////////////////////////////////

Uso ANJUTA 2.30.1.0 en Debian SID, al Compilar no me genera errores, al construir aparece esto:

main.cc:24: undefined reference to `mysql_init'
main.cc:29: undefined reference to `mysql_real_connect'
main.cc:31: undefined reference to `mysql_error'
main.cc:53: undefined reference to `mysql_close'
collect2: ld returned 1 exit status
make: *** [foobar_cpp] Error 1
Completado incorrectamente

He probado compilando esto g++ main.cc -o main -L/usr/lib/mysql -lmysqlclient
y me compila sin problemas...

Alguien sabe como puedo hacer para solucionar este error???