Reputation: 925
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?
Upvotes: 6
Views: 40055
Reputation: 4583
g++ -o Programname $(mysql_config --cflags) Programfile.cpp $(mysql_config --libs)
Does the trick in Linux.
Upvotes: 1
Reputation: 5127
For me, on Ubuntu 12.04, I needed to use this include
#include <mysql/mysql.h>
Upvotes: 7
Reputation: 4059
#include "path-spec"
#include <path-spec>
Both syntax forms cause replacement of that directive by the entire contents of the specified include file. The difference between the two forms is the order in which the preprocessor searches for header files when the path is incompletely specified.
#include "path-spec"
instructs the preprocessor to look for include files in the same directory of the file that contains the #include statement, and then in the directories of any files that include (#include) that file. The preprocessor then searches along the path specified by the /I compiler option, then along paths specified by the INCLUDE environment variable.
#include <path-spec>
instructs the preprocessor to search for include files first along the path specified by the /I compiler option, then, when compiling from the command line, along the path specified by the INCLUDE environment variable.
I don't know what compiler you are using, but it may require you to add your includes and libs to the compilation:
g++ bla.cpp -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient_r
Upvotes: 1
Reputation: 3021
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.
Upvotes: 8
Reputation: 11
Did you try to give the include statement a full path to the file?
Upvotes: 1