PDA

View Full Version : Running c code in terminal : "command not found" error




jakee.stoltz
Sep 17, 2010, 12:40 PM
I'm trying to run my .c file through terminal but keep running into the same problem. I use "gcc" and the file name but no matter what I try, it keeps giving me "-bash: gcc: command not found".

Here is a screenshot.
http://i43.photobucket.com/albums/e366/bassist11/Screenshot2010-09-17at122617PM.png

What am I doing wrong?

Thanks



robbieduncan
Sep 17, 2010, 12:48 PM
Have you installed the Developer Tools (or gcc on it's own via other means)? OSX does not have gcc installed by default...

jakee.stoltz
Sep 17, 2010, 12:55 PM
I have a folder on my HD called Developer and it's full of stuff. I installed XCode quite a while ago so I don't remember for sure. How would I know for sure?

robbieduncan
Sep 17, 2010, 12:57 PM
If you do /usr/bin/gcc what do you get. I get this:


Robert-Duncans-MacBook-Pro:~ robbie$ ls -l /usr/bin/gcc
lrwxr-xr-x 1 root wheel 7 15 Sep 21:11 /usr/bin/gcc -> gcc-4.2

jakee.stoltz
Sep 17, 2010, 01:24 PM
jakee-stoltzs-macbook:~ JakeeStoltz$ /usr/bin/gcc
-bash: /usr/bin/gcc: No such file or directory

That's what I get. So apparently I don't have that installed.

Do I just install gcc from the OS disc, sort of like installing XCode?

robbieduncan
Sep 17, 2010, 01:26 PM
Download and install the latest Developer Tools.

jakee.stoltz
Sep 17, 2010, 01:31 PM
Alright. Will do. I've updated to Snow Leopard since I installed XCode so I'm probably a version behind in that anyways.

Thanks for the help.

robbieduncan
Sep 17, 2010, 01:33 PM
Alright. Will do. I've updated to Snow Leopard since I installed XCode so I'm probably a version behind in that anyways.

Thanks for the help.

That's almost certainly what caused this. I don't think the developer tools survive .x upgrades (but the do survive .x.y).

mlts22
Sep 17, 2010, 01:52 PM
As a matter of practice, I always wipe and install clean when doing .x releases. .x.y are different, but I've found that it is always better to have no cruft behind when doing major upgrades.

jakee.stoltz
Sep 17, 2010, 02:18 PM
Got it working. Thanks a lot robbieduncan!