Take the 2-minute tour ×

I was trying to add a new library/header and seem to have broken gcc. Specifically, I used the command:

$ sudo cp mylib.h /usr/local/include

This seems to have replaced the /usr/ directory with a file because I get the following error when trying to compile trivial programs

cc1: error: /usr/local/include: not a directory

I can't find the file or directory, but then again I don't know where to look. Is there a way to recreate the /usr/local/include directory? Can I simply reinstall gcc?

P.S. I know using sudo was a stupid mistake. I was bone-headly following some instructions I found online.

Any advice as to where I should look would be greatly appreciated.

[edit] I am using mac OSX 10.6.

share|improve this question

migrated from stackoverflow.com Jun 20 '11 at 20:28

This question came from our site for professional and enthusiast programmers.

What do you get when you type ls /usr/local/include –  GWW Jun 20 '11 at 20:20
/usr/local/include –  shamaniacal Jun 20 '11 at 20:21
That wasn't very helpful was it ;) –  Nix Jun 20 '11 at 20:22
just remove the file sudo rm /usr/local/include, and create directory sudo mkdir /usr/local/include, then install your header with sudo cp mylib.h /usr/local/include/ –  Banthar Jun 20 '11 at 20:23
@shamaniacal: It sounds like the folder /usr/local/include didn't previously exist. You need to create the folder first and then copy your library file into it –  GWW Jun 20 '11 at 20:23
show 5 more comments

3 Answers

up vote 3 down vote accepted

Sounds to me like you didn't have a /usr/local/include to start with; so that command will have created it, as the file you wanted to copy. To fix that:

sudo mv /usr/local/include /usr/local/mylib.h
sudo mkdir /usr/local/include
sudo mv /usr/local/mylib.h /usr/local/include

(I highly encourage you to verify this first, as you should have the first time.

file /usr/local/include    # should say "C program text" or similar
less /usr/local/include    # should be your mylib.h


share|improve this answer
add comment

If the /usr/local/include previously existed, simply reinstalling gcc isn't going to be the complete solution.

If you have installed any other *-devel libraries you are going to have to reinstall them as well.

share|improve this answer
add comment

In Terminal type the command "defaults write com.apple.finder AppleShowAllFiles TRUE", then type "killall Finder". Now you should be able to see the usr directory in the root directory of your boot drive. If you have replace your usr directory with a file you should probably look around for a copy of it.

share|improve this answer
add comment

Your Answer


