hi,
i'm trying to interface with a mysql db from C++ and I'm getting weird compilation errors. i'm running Slackware7.0.
this is the program:
Code:
#include <mysql/mysql.h>
#include <stdio.h>
#define host "127.0.0.1"
#define username "root"
#define password ""
#define db "ccnums"
int main()
{
MYSQL *conn;
conn = mysql_init(NULL);
mysql_real_connect(conn, host, username, password, db, 0, NULL, 0);
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i;
mysql_query(conn, "select * from nums");
res_set = mysql_store_result(conn);
unsigned int numrows = mysql_num_rows(res_set);
while((row = mysql_fetch_row(res_set)) != NULL)
{
for (i=0; i<mysql_num_fields(res_set); i++)
printf("%s\n", row[i] != NULL ? row[i] : "NULL");
}
mysql_close(conn);
return 0;
}
and the errors:
Code:
/tmp/ccVA60Wf.o: In function `main':
/tmp/ccVA60Wf.o(.text+0xc): undefined reference to `mysql_init'
/tmp/ccVA60Wf.o(.text+0x37): undefined reference to `mysql_real_connect'
/tmp/ccVA60Wf.o(.text+0x4b): undefined reference to `mysql_query'
/tmp/ccVA60Wf.o(.text+0x5a): undefined reference to `mysql_store_result'
/tmp/ccVA60Wf.o(.text+0x6e): undefined reference to `mysql_num_rows'
/tmp/ccVA60Wf.o(.text+0x88): undefined reference to `mysql_fetch_row'
/tmp/ccVA60Wf.o(.text+0xaf): undefined reference to `mysql_num_fields'
/tmp/ccVA60Wf.o(.text+0x10d): undefined reference to `mysql_close'
collect2: ld returned 1 exit status
i'd appreciate it if someone would clear this up for me.
Martin