gcc 编译 mysql 出错_linux下C API连接mysql编译出错 求助啊!!!

#include#include"/usr/local/mysql-5.1.51/include/mysql.h"intmain(){char*user="root",*pwd="mysql",*dbname="test";MYSQLmysql;MYSQL_RES*mysql_ret;MYSQL_ROWmysql_row...

#include

#include "/usr/local/mysql-5.1.51/include/mysql.h"

int main()

{

char *user="root", *pwd= "mysql", *dbname= "test";

MYSQL mysql;

MYSQL_RES *mysql_ret ;

MYSQL_ROW mysql_row;

long int num_rows;

unsigned long int ret;

mysql_init(&mysql);

if(mysql_real_connect(&mysql,NULL,user,pwd,dbname,0,NULL,0))

{

printf("Connection success!\n ");

ret = mysql_query(&mysql, "select * from emp ");

if(!ret)

{

printf( "Query Success!\n ");

mysql_ret=mysql_store_result(&mysql);

if(mysql_ret!= NULL)

{

printf("Store Result Success!\n");

num_rows= mysql_num_rows(mysql_ret);

if(num_rows!= 0)

{

printf( "%d\n ",num_rows);

while(mysql_row = mysql_fetch_row(mysql_ret))

{

for(int i=0;i

printf("%s ",mysql_row[i]);

printf("\n");

}

}

else

{

printf( "mysql_num_rows Failed!\n ");

exit(-1);

}

mysql_free_result(mysql_ret);

exit(0);

}

else

{

printf( "Store Result Failed!\n ");

exit(-1);

}

}

else

{

printf( "Query Failed!\n ");

exit(-1);

}

}

else

{

printf( "Connection Failed\n ");

exit(-1);

}

return 0;

}

以上代码到demo.c中 mysqlclient库文件到usr/local/mysql-5.1.51/lib

编辑gcc demo.c -L/usr/local/mysql-5.1.51/lib -lmysqlclient -o example

报错:

demo.c: In function 鈓ain?

demo.c:29: error: 鈌or?loop initial declaration used outside C99 mode

demo.c:37: warning: incompatible implicit declaration of built-in function 鈋xit?

demo.c:40: warning: incompatible implicit declaration of built-in function 鈋xit?

demo.c:45: warning: incompatible implicit declaration of built-in function 鈋xit?

demo.c:51: warning: incompatible implicit declaration of built-in function 鈋xit?

demo.c:57: warning: incompatible implicit declaration of built-in function 鈋xit

这是什么问题啊 ?? 大侠求助!!!

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值