mysql header files: "No such file or directory"
I've set up MySQL in my new Mac environment (Lion 10.7.3). It's all been working fine running the AJAX dev environment. But now I want to do a bit of batch tinkering on the db, and so I tried compiling some old C code.
I installed the
Command Line Tools
in Xcode to get gcc
working. I used sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
so that the libmysqlclient.18.dylib
could be found.
I got stuck because I did't know how to point to the right directory to find
mysql.h
.
My compile code was
gcc -Wall upload-comments.c -lmysqlclient -o upload-comment
although that's working fine. The error it gets is:
upload-comments.c:13:20: error: mysql.h:No such file or directory
I'm sure it just takes a line of
sudo
brilliance, but I don't know what it is, and my web trawling isn't helping me find it.
I followed some advice, and changed the compile line to:
gcc -Wall upload-comments.c -l -o upload-comments -I/usr/local/mysql/include
.
You'll note I removed the
-lmysqlclient
reference because it couldn't find it. This may be a mistake.
Now, however,
mysql.h
is complaining that it can't find other libraries. Why would this be?
In file included from upload-comments.c:14:
/usr/include/mysql.h:71:27: error: mysql_version.h:No such file or directory
/usr/include/mysql.h:72:23: error: mysql_com.h:No such file or directory
/usr/include/mysql.h:73:24: error: mysql_time.h:No such file or directory
/usr/include/mysql.h:75:70: error: my_list.h:No such file or directoryIn file included from upload-comments.c:14:
/usr/include/mysql.h:114: error: field ‘type’ has incomplete type
/usr/include/mysql.h:131:21: error: typelib.h:No such file or directory
/usr/include/mysql.h:146:22: error: my_alloc.h:No such file or directory
Why can it not find these files? They are all there in /usr/local/mysql/include.
Ideally, I'd like to set up the environment so that the redirections are permanent and don't need to be added as an
-I/usr...
addition to every compilation command.
Any help will be gratefully received 🙂
iMac, Mac OS X (10.7.3)