I have updated to Xcode to v4.2.1 from v3 and it works fine but as a C newbie I want to code in Text Wrangler and compile with gcc in the CLI.
gcc returns ‘command not found’ for some reason now (it worked fine earlier)
After some googling I figured out gcc was moved to /Developer/usr/bin from /usr/bin (I can see it there).
Now gcc runs when I use the exact path but it can’t find any of the header files.
my-MacBook-Pro:Desktop user$ /Developer/usr/bin/gcc -o program program.c
program.c:15:19: error: stdio.h: No such file or directory
program.c:16:18: error: math.h: No such file or directory
program.c:17:20: error: stdlib.h: No such file or directory
program.c: In function ‘main’:
program.c:33: warning: incompatible implicit declaration of built-in function ‘malloc’
program.c:35: warning: incompatible implicit declaration of built-in function ‘sqrt’
program.c:44: warning: incompatible implicit declaration of built-in function ‘printf’
program.c:65: warning: incompatible implicit declaration of built-in function ‘printf’
Any help is greatly appreciated.
In Xcode 4.3+ the ‘Command Line Tools’ package is not installed by default. You can download it in Preferences -> Downloads. Note that you need Lion.
EDIT:
In Xcode < 4.3 the Command Line Tools is included in the Xcode install, so the above solution doesn’t apply.
However, try using xcode-select: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
EDIT 2:
Install Command Line Tools for Xcode from the downloads section on the Apple dev site.