[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
MySQL C APIs
Hi friends,
I am writing a C program to access a MySQL database. I
have MySQL-3.23.31 server, client and MySQL-devel
which I had installed using their respective .rpm
installers. I am compiling the program named "myapp.c"
using the following command line parameters.
$cc -L/usr/lib/mysql myapp.c -o myapp -lm
-lmysqlclient
The error message that I get is:
/usr/lib/mysql/libmysqlclient.a(my_compress.o): In
function `my_uncompress':
my_compress.o(.text+0x97): undefined reference to
`uncompress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o): In
function `my_compress_alloc':
my_compress.o(.text+0x12b): undefined reference to
`compress'
collect2: ld returned 1 exit status
I have tried the same using the MySQL-devel versions
3.23.33, 3.23.32, 3.23.31, 3.23.30, 3.23.29a and am
still obtaining the same result.
Can anybody tell me what changes I have to make to run
the app.
Thanks in advance.
Sunil Parolia,
paroliasunil@xxxxxxxxxx
-------------------------------------------------------
Code of myapp.c
#include <stdio.h>
#define HOST "Linux"
#define USERNAME "mysql"
#define PASSWORD ""
#include <stdlib.h>
#include "mysql.h"
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
void exiterr(int exitcode)
{
printf( "%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,"test"))
exiterr(2);
if (mysql_query(&mysql,"SELECT col1,col2 FROM
test"))
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);
}
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/