linux下C语言连接MySQL数据库找不到mysql.h头文件


在linux下写C语言连接MySQL数据库时编译出错:

请输入图片描述

代码:

   
  #include <stdlib.h>
  
#include <stdio.h>

#include "mysql.h"

int main(int argc,char *argv[])
{
MYSQL *conn_ptr;
conn_ptr = mysql_init(NULL);

if(!conn_ptr)
{
fprintf(stderr,"mysql_init failed\n");
return EXIT_FAILURE;
}

conn_ptr = mysql_real_connect(conn_ptr,"localhost","rick","rick","foo",0,NULL,0);

if(!conn_ptr)
printf("Connection success\n");
else
printf("Connection failed\n");

mysql_close(conn_ptr);

return EXIT_SUCCESS;
}

我的系统是ubuntu11.10,我已经在Ubuntu Software Center安装了MySQL客户端和服务器。为什么还锁找不到头文件呢?

Linux c mysql

pengwar 11 years, 7 months ago

我使用centos的话,是另外从官网下载mysql客户端支持包

orchid answered 11 years, 7 months ago

Your Answer