Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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)

Posted on May 8, 2012 11:45 PM

Reply
Question marked as Best reply

Posted on May 9, 2012 8:08 AM

nicknliz wrote:


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.


Don't do that. Link with -L and then use "install_name_tool" to fix up the binary afterwards.

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.


No more sudo "brilliance" please 🙂. Stay off the web too. It is a fountain of misinformation.


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.


It is. You still need to link against MySQL.


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.


Because you seem to have added a link or something to /usr/include/mysql.h. Get rid of that.


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.


But that is the correct way to do it. It is permanent. When you hack up your system, it will break in six months when you update and you will have to remember what hacks you did and re-create them. If you compile it properly, it will always work.

1 reply
Question marked as Best reply

May 9, 2012 8:08 AM in response to nicknliz

nicknliz wrote:


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.


Don't do that. Link with -L and then use "install_name_tool" to fix up the binary afterwards.

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.


No more sudo "brilliance" please 🙂. Stay off the web too. It is a fountain of misinformation.


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.


It is. You still need to link against MySQL.


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.


Because you seem to have added a link or something to /usr/include/mysql.h. Get rid of that.


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.


But that is the correct way to do it. It is permanent. When you hack up your system, it will break in six months when you update and you will have to remember what hacks you did and re-create them. If you compile it properly, it will always work.

mysql header files: "No such file or directory"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.