rezon
rezon

Reputation: 45

fatal error: 'mysql/mysql.h' file not found

I have installed mysql using

brew install mysql

Then compiled using

gcc -I/usr/include mydb.c

However it gives me the error:

fatal error: 'mysql/mysql.h' file not found

What am I doing wrong here? Am on macosx 10.12

edit: tried gcc -I/usr/local/include/mysql/ mydb.c still broken

Upvotes: 2

Views: 4047

Answers (2)

Santos L. Victor
Santos L. Victor

Reputation: 658

Verify at where are install mysql, for this, using the command for see the file list of directory

ls

and using

cd

The installation, in my example, are is in directory:

/usr/local/mysql-<version_my_mysql>/include/

second step is indicate the directory everytime compiller:

gcc my_program_code_file.c -I /usr/local/mysql-5.7.9-osx10.9-x86_64/include/ -o my_program_executable

the includers in code are:

#include <mysql.h>

Upvotes: 0

hanxinle
hanxinle

Reputation: 21

On ubuntu16.04,mysql.h locates in /usr/include/mysql. You can find it after install libmysqlclient20 or libmysqlclient-dev.

Upvotes: 1

Related Questions