tags:

views:

771

answers:

4

I'm building an open source project from source,

and it need to include <mysql.h>:

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

and the compilor reports:

mysql.h no such file or directory

MySQL is yet another greater open source project,what do I need to do to make it work?

A: 

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

proglammer
and when you have to change your development environment what will you do?
klez
@klez: testing with the full path to the file *is* valid as a test to see if it work. Of course it shouldn't be left that way...
FrustratedWithFormsDesigner
@FrustratedWithFormsDesigner yes, that's what I meant :-)
klez
Although full paths in `#include` directives are allowed, they are discouraged. A better practice is to add folders to the compiler's list and remove them from the `#include` directive.
Thomas Matthews
agreed with everyone! rephrased: "did you try to include the full path to the file just for test purposes, to see if the compiler tries to get the correct path?"
proglammer
+3  A: 

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.

KevenK
I have neither `mysql.h` nor `mysql.lib`,where should I download it?
symfony
@symfony: EPIC FAIL XD How do you expect to include a file you don't have?
klez
Try this: http://www.google.com/search?q=download+mysql+source
FrustratedWithFormsDesigner
Is the libs included in the source download?
symfony
@symfony, you could download it and see. You're only ~20MB from finding out.
jball
+1  A: 
#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
o15a3d4l11s2
Actually, it has nothing to do with the -I option -- unless you're on GCC. It'd be more correct to say it asks the compiler to look for the header, rather than using a relative path to the current file being compiled. So, -1 for not being completely correct, but +1 for getting the gist of the information the OP needs.
Billy ONeal
A: 

From Where i download mysql.h header...

plzzz any one send me link on [email protected]....

its is very urgent.....

thanks.. in advance

Shushank