I’m trying to compile with this command line (in OSX):
gcc -Wall upload-comments.c -l -o upload-comments -I/usr/local/mysql/include/ -L/usr/local/mysql/lib/ -lmysqlclient
It comes back with the error:
upload-comments.c:14:20: error: mysql.h: No such file or directory
mysql.h is clearly in /usr/local/mysql/include/
Why is it not finding the header file?
Thanks.
You need to put the
-I...bit before the source files that need it.The
gcccommand is position-sensitive, both for that and the libraries (you should list libraries after the files that need them, for example).I’m also not sure why you have a naked library name specifier (
-lwithout an actual library name). That seems like it may cause problems to me but it’s irrelevant to the specific issue raised.You may want to remove it if, after you fix your command according to this answer, you still have problems.