SETUP
OS X 10.8
Xcode 4.4.1 installed
TextMate 2 -r9283
SUMMARY
Compiling and running a simple C program in TextMate2 on 10.8 with Xcode 4.4 installed gives me a path error, then a compiler error, then a linker error.
STEPS TO REPRO
- Create a file called
test.cin TextMate2 and save to Desktop -
Paste this program in the
test.cfile:#include <stdio.h>int main(int argc, char const *argv[]) { printf("Hello World\n"); return 0; }
- Type
command-Rfor Run
EXPECTED RESULT
Output from stdout from running the program
ACTUAL RESULT
The TextMate output panel shows me this PATH error:
Can't find “gcc” on PATH.
The current PATH is:
/usr/bin
/bin
/usr/sbin
/sbin
/Users/itod/Library/Application Support/TextMate/Managed/Bundles/Bundle Support.tmbundle/Support/shared/bin
Please add the directory containing “gcc” to PATH in TextMate's Shell Variables preferences.
then this compiler error:
cc1: error: stdio.h: No such file or directory
then this linker error:
ld: library not found for -lcrt1.10.6.o
collect2: ld returned 1 exit status
How do I fix these errors and successfully compile and run a C program in TextMate 2 in OS X 10.8?
If you want
/usr/bin/gccetc. properly installed, get the “Command Line Tools for Xcode” from the apple developer site http://developer.apple.com/downloads (free download with free ADC account). It will install /usr/bin binaries for all the commandline tools – gcc, ld, etc.