Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include the mysql header?

Tags:

c++

mysql

build

I'm building an open source project from source,

and it needs to include <mysql.h>:

#if USE_MYSQL
#include <mysql.h>
#endif

and the compiler reports:

mysql.h no such file or directory

MySQL is yet another great open source project. What do I need to do to make it work?

like image 876
symfony Avatar asked Mar 25 '10 14:03

symfony


3 Answers

This will be entirely dependent on your build methods, whether that's using an IDE like Visual Studio, Eclipse, etc, or if you're using shell scripts and command lines in *nix.

You will need to make sure that that file (mysql.h) exists in your 'includes' path.

For example, in Visual Studio, you would go into:

Project Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories

And include the directory to which you have 'mysql.h' saved.

Then, for your linker properties, repeat the steps and include the respective DLL/LIB file path in your Additional Library Directories

This will differ greatly depending on your environment, so more information would be needed for exact step-by-steps. But this should explain the actual Problem.

like image 90
KevenK Avatar answered Oct 06 '22 18:10

KevenK


For me, on Ubuntu 12.04, I needed to use this include

#include <mysql/mysql.h>
like image 38
mrk Avatar answered Oct 06 '22 18:10

mrk


Did you try to give the include statement a full path to the file?

like image 28
proglammer Avatar answered Oct 06 '22 16:10

proglammer