UNDEFINED REFERENCE TO mysql_init
UNDEFUNED REFERENCE TO mysql_real_connect
y asi con cada funcion de mysql.h
estoy usando anjuta, y mi directorio de instalacion de MYSQL es el que trae por defecto el XAMPP para linux.
Cita:
#include <iostream>
#include <mysql/mysql.h>
int main()
{
MYSQL mysql;
MYSQL_RES* result;
MYSQL_ROW row;
MYSQL_FIELD* field;
int n_rows = 0;
int i,j;
if (! mysql_init (&mysql)){
printf("Erreur d'allocationn");
}
if (! mysql_real_connect(&mysql,"localhost","user","pass word","base",0,NULL,0)) {
printf("Erreur de connexionn");
}
mysql_query (&mysql,"SELECT votre_colonne FROM table");
result = mysql_store_result (&mysql);
n_rows = mysql_num_rows(result);
for(j=0; j<n_rows;j++){
i=0;
mysql_field_seek(result,0);
row = mysql_fetch_row(result);
while(j<n_rows){
printf ("%s: ",field->name);
printf ("%sn ",row++);
}
printf("n");
}
mysql_free_result(result);
mysql_close(&mysql);
return 0;
}
#include <mysql/mysql.h>
int main()
{
MYSQL mysql;
MYSQL_RES* result;
MYSQL_ROW row;
MYSQL_FIELD* field;
int n_rows = 0;
int i,j;
if (! mysql_init (&mysql)){
printf("Erreur d'allocationn");
}
if (! mysql_real_connect(&mysql,"localhost","user","pass word","base",0,NULL,0)) {
printf("Erreur de connexionn");
}
mysql_query (&mysql,"SELECT votre_colonne FROM table");
result = mysql_store_result (&mysql);
n_rows = mysql_num_rows(result);
for(j=0; j<n_rows;j++){
i=0;
mysql_field_seek(result,0);
row = mysql_fetch_row(result);
while(j<n_rows){
printf ("%s: ",field->name);
printf ("%sn ",row++);
}
printf("n");
}
mysql_free_result(result);
mysql_close(&mysql);
return 0;
}