Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error mysql.h:No such file or directory during compilation

I have the following code

#include <my_global.h>
#include <mysql.h>

int main(int argc, char **argv)
{
  printf("MySQL client version: %s\n", mysql_get_client_info());

  exit(0);
}

when i try to compile it using

gcc mysqldb.c -o mysql -I/usr/include/mysql -lmysqlclient 

i get an error saying fatal error mysql.h:No such file or directory. how can i successfully compile and run the code

like image 868
user2883880 Avatar asked Jan 03 '14 17:01

user2883880


1 Answers

I come across the same error today, turn out that I forget to install package libmysqlclient-dev. After I install it with

sudo apt install libmysqlclient-dev

the error went away.

like image 151
fengqi Avatar answered Nov 09 '22 14:11

fengqi