goon12
04-05-2002, 12:52 AM
I am trying to connect to mysql db that is sitting on the local machine.. I tried #include "mysql.h" and the file was sitting the working directory.
I am getting this error:
cc test_db.c -o test_db
/tmp/ccI7b81q.o: In function `main':
/tmp/ccI7b81q.o(.text+0x20): undefined reference to `mysql_connect'
/tmp/ccI7b81q.o(.text+0x42): undefined reference to `mysql_select_db'
/tmp/ccI7b81q.o(.text+0x59): undefined reference to `mysql_query'
/tmp/ccI7b81q.o(.text+0x6b): undefined reference to `mysql_store_result'
/tmp/ccI7b81q.o(.text+0x8b): undefined reference to `mysql_fetch_row'
/tmp/ccI7b81q.o(.text+0xcb): undefined reference to `mysql_num_fields'
collect2: ld returned 1 exit status
make: *** [test_db] Error 1
What am I doing wrong? Here is the simple simple program:
#include "mysql.h"
#include<stdlib.h>
#include<stdio.h>
int main()
{
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
if (!(mysql_connect(&mysql, "xxx.xxx.xxx.xxx", "xxx", "xxxx")))
{
abort();
}
mysql_select_db(&mysql, "MyDataBase");
mysql_query(&mysql, "select id, username, email from user_accounts");
res = mysql_store_result(&mysql);
while((row = mysql_fetch_row(res)))
{
uint i = 0;
for(i=0; i < mysql_num_fields(res); i++)
{
printf("%s\n", row[i]);
}
}
exit(0);
}
Thanks,
goon12
I am getting this error:
cc test_db.c -o test_db
/tmp/ccI7b81q.o: In function `main':
/tmp/ccI7b81q.o(.text+0x20): undefined reference to `mysql_connect'
/tmp/ccI7b81q.o(.text+0x42): undefined reference to `mysql_select_db'
/tmp/ccI7b81q.o(.text+0x59): undefined reference to `mysql_query'
/tmp/ccI7b81q.o(.text+0x6b): undefined reference to `mysql_store_result'
/tmp/ccI7b81q.o(.text+0x8b): undefined reference to `mysql_fetch_row'
/tmp/ccI7b81q.o(.text+0xcb): undefined reference to `mysql_num_fields'
collect2: ld returned 1 exit status
make: *** [test_db] Error 1
What am I doing wrong? Here is the simple simple program:
#include "mysql.h"
#include<stdlib.h>
#include<stdio.h>
int main()
{
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
if (!(mysql_connect(&mysql, "xxx.xxx.xxx.xxx", "xxx", "xxxx")))
{
abort();
}
mysql_select_db(&mysql, "MyDataBase");
mysql_query(&mysql, "select id, username, email from user_accounts");
res = mysql_store_result(&mysql);
while((row = mysql_fetch_row(res)))
{
uint i = 0;
for(i=0; i < mysql_num_fields(res); i++)
{
printf("%s\n", row[i]);
}
}
exit(0);
}
Thanks,
goon12