#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <mysql/mysql.h>
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
char host<>="localhost";
char user<>="root";
char passwd<>="dmswn^^audtn";
void exiterr(int exitcode)
{
fprintf(stderr, "%s", mysql_error(&mysql));
exit(exitcode);
}
int main(void)
{
int i=0;
if(!(mysql_connect(&mysql, host, user, passwd)))
exiterr(1);
if(mysql_select_db(&mysql, "mysql"))
exiterr(2);
if(mysql_query(&mysql, "SELECT * FROM db"))
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", row[i]);
}
if(!mysql_eof(res))
exiterr(5);
mysql_free_result(res);
mysql_close(&mysql);
return 0;
}
이것을 컴파일하면 아래와 같은 에러가 납니다...
/tmp/cccm1gy0.o: In function `exiterr':
/tmp/cccm1gy0.o(.text+0x12): undefined reference to `mysql_error'
/tmp/cccm1gy0.o: In function `main':
/tmp/cccm1gy0.o(.text+0x5e): undefined reference to `mysql_connect'
/tmp/cccm1gy0.o(.text+0x86): undefined reference to `mysql_select_db'
/tmp/cccm1gy0.o(.text+0xae): undefined reference to `mysql_query'
/tmp/cccm1gy0.o(.text+0xd1): undefined reference to
`mysql_store_result'
/tmp/cccm1gy0.o(.text+0x102): undefined reference to `mysql_fetch_row'
/tmp/cccm1gy0.o(.text+0x12e): undefined reference to `mysql_num_fields'
/tmp/cccm1gy0.o(.text+0x172): undefined reference to `mysql_eof'
/tmp/cccm1gy0.o(.text+0x196): undefined reference to
`mysql_free_result'
/tmp/cccm1gy0.o(.text+0x1a6): undefined reference to `mysql_close'
collect2: ld returned 1 exit status
뭐가 문제인지 몰르겠습니다...
다른 것을 설치 해야되나엽....
고수님 잘 가르쳐 주세요