linking mysql databse with C++ programming

when i execute this program in konsole
#include <stdio.h>
#include "/usr/include/mysql/mysql.h"

int main()
{
MYSQL *mysql;
MYSQL_RES *RESULT;
MYSQL_ROW ROW;
if(mysql_init(mysql)==NULL)
{
fprintf(stderr,"cannot initialize MYSQL");
return 1;
}
if(!mysql_real_connect(mysql,"localhost","user","password","data",0,NULL,0))
{
fprintf(stderr," %d:%s\n",mysql_errno(mysql),mysql_error(mysql));
return 1;

}

The errors
are
guido@mapped-129-120-38-131:~/c_files> g++ data.cpp
/tmp/ccthAKzt.o: In function `main':
data.cpp:(.text+0x12): undefined reference to `mysql_init'
data.cpp:(.text+0x8e): undefined reference to `mysql_real_connect'
data.cpp:(.text+0xa3): undefined reference to `mysql_error'
data.cpp:(.text+0xb1): undefined reference to `mysql_errno'
collect2: ld returned 1 exit status
You need to link to the mysql client library

http://dev.mysql.com/doc/refman/5.0/en/building-clients.html
Topic archived. No new replies allowed.