找不到mysql.h_c++ 找不到mysql.h文件

我正在ubuntu 12.04中安装c和mysql之间的连接。我已经安装了mysql-client,mysql-server,libmysqlclient15-dev,libmysql -dev。但是当我尝试编译代码时,我收到错误:mysql.h没有这样的文件。我看着文件夹,有mysql.h文件,我不明白为什么它找不到它。这是我的代码:

/* Simple C program that connects to MySQL Database server*/

#include

#include

main() {

MYSQL *conn;

MYSQL_RES *res;

MYSQL_ROW row;

char *server = "localhost";

char *user = "root";

//set the password for mysql server here

char *password = "*********"; /* set me first */

char *database = "Real_flights";

conn = mysql_init(NULL);

/* Connect to database */

if (!mysql_real_connect(conn, server,

user, password, database, 0, NULL, 0)) {

fprintf(stderr, "%s\n", mysql_error(conn));

exit(1);

}

/* send SQL query */

if (mysql_query(conn, "show tables")) {

fprintf(stderr, "%s\n", mysql_error(conn));

exit(1);

}

res = mysql_use_result(conn);

/* output table name */

printf("MySQL Tables in mysql database:\n");

while ((row = mysql_fetch_row(res)) != NULL)

printf("%s \n", row[0]);

/* close connection */

mysql_free_result(res);

mysql_close(conn);

}

它的工作,但现在我面临另一个错误,如:

mysql.c: In function ‘main’:

mysql.c:21: warning: incompatible implicit declaration of built-in function ‘exit’

mysql.c:27: warning: incompatible implicit declaration of built-in function ‘exit’

/tmp/ccinQBp8.o: In function `main':

mysql.c:(.text+0x3e): undefined reference to `mysql_init'

mysql.c:(.text+0x5e): undefined reference to `mysql_real_connect'

mysql.c:(.text+0x70): undefined reference to `mysql_error'

mysql.c:(.text+0xa5): undefined reference to `mysql_query'

mysql.c:(.text+0xb7): undefined reference to `mysql_error'

mysql.c:(.text+0xe7): undefined reference to `mysql_use_result'

mysql.c:(.text+0x11c): undefined reference to `mysql_fetch_row'

mysql.c:(.text+0x133): undefined reference to `mysql_free_result'

mysql.c:(.text+0x141): undefined reference to `mysql_close'

collect2: ld returned 1 exit status

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值