Hi,

I need help on compiling with the C APIs.

mysql v3.22.30
glibc-2.1.2-11

source code:

#include <stdio.h>
#include <stdlib.h>
#include <mysql.h>

MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;

void exiterr(int exitcode){
 fprintf( stderr, "%s\n", mysql_error(&mysql) );
  exit( exitcode );
}

int main(){
  uint i = 0;
  if (!(mysql_connect(&mysql,"host","username","password")))
    exiterr(1);
  if (mysql_select_db(&mysql,"payroll"))
    exiterr(2);
  if (mysql_query(&mysql,"SELECT name,rate FROM emp_master"))
    exiterr(3);
  if (!(res = mysql_store_result(&mysql)))
    exiterr(4);
  while((row = mysql_fetch_row(res)))
    for (i=0 ; i < mysql_num_fields(res); i++)
       printf("%s\n",row[i]);
  if (!mysql_eof(res))
    exiterr(5);
  mysql_free_result(res);
  mysql_close(&mysql);
}

link command:
gcc -o test test.c -L/usr/lib/mysql -lmysqlclient

outcome:
/usr/lib/mysql/libmysqlclient.a(my_open.o): In function `my_open':
my_open.o(.text+0x14): undefined reference to `open64'
/usr/lib/mysql/libmysqlclient.a(mf_format.o): In function `fn_format':
mf_format.o(.text+0x208): undefined reference to `__lxstat64'
/usr/lib/mysql/libmysqlclient.a(my_fopen.o): In function `my_fopen':
my_fopen.o(.text+0x21): undefined reference to `fopen64'
collect2: ld returned 1 exit status

what's wrong with it ? where i can find these references ?

Thanks for your help

Regards

Jeremy Cluzel

Reply via email to