I have some C code that #include
s the file <mysql/mysql.h>
. I am running on a Mac, and cannot figure out how to get mysql
installed (after running the solution found on SO, the mysql
directory does not even exist in the system library). I was able to download MySQL from the source code, and now I have a mysql.h
file-- in the "include" directory of the source code.
However, moving this file into the system library alone will obviously not make my program work. I expect that I need to compile the library (which I've done), and to move the binary file somewhere, in order to be linkable to my program.
As per @RustyX's suggestion, I installed the Mac MySQL package. That put a copy of mysql.h
into the /usr/local/mysql-5.7.19-macos10.12-x86_64/include/
directory. However:
1) I am using gcc
to compile the .c file. I am not sure how to configure gcc
to include the directory in question. I tried
-L(directory path)
-- both for the installed Mac MySQL package, and the MySQL source code I downloaded-- but I get the following error:
ld: library not found for -lmysqlclient
Is there another path I would include for mysqlclient
? Or another package to install?
2) Even if I do include it, it will still not find the file since the called-for filename is <mysql/mysql.h>
, and the filename it will find is <include/mysql.h>
. Since the file is used by others, is the best course of action here to rename the include
directory to mysql
? Or to change the path in the .c file, and then change it back every time before committing?
Have you tried a statement like this,
To compile and run