When I installed Xcode on Snow Leopard, gcc was not in my path. I manually added /Developer/bin to get gcc. However, I wrote a simple C program to include stdlib.h and stdio.h and print a string, but I get linker errors.

I think this is because I don't have my include path configured. Can anyone tell me why this was not done automatically and how I can get my C compiler set up?

  • I too had macs with Xcode 4.1 where the path didn't include gcc. Cleaning the old path changes and old binaries let the latest installer fix things to run "out of the box"
    – bmike
    Sep 21, 2011 at 14:33
  • For what it's worth I ended up just reformatting hahahah! It would appear the company computer I've inherited was not a clean install (I was told it was), so my solution is to just whipe it out... oh well! Sep 21, 2011 at 19:18
  • I too have taken to clean wiping more and more of my "Lion" upgrades. See Is there a second step...
    – bmike
    Sep 21, 2011 at 19:21

2 Answers 2


I think there was a bug in Xcode 4.1 where the command line tools were not installed. I just ran the 4.1.1 delta installer from the App Store and things work just fine.

Last login: Tue Sep 20 14:47:44 on ttys001
mac:~ mike$ which gcc
mac:~ mike$ ls -l /usr/bin/gcc
lrwxr-xr-x  1 root  wheel  12 Sep 19 16:04 /usr/bin/gcc -> llvm-gcc-4.2
mac:~ mike$ echo $PATH
mac:~ mike$ mkdir /tmp/test
mac:~ mike$ cat > /tmp/test/hello.c << EOF
/* Hello World program */


    printf("Hello World");

mac:~ mike$ cd /tmp/test
mac:test mike$ gcc hello.c -o hello
mac:test mike$ ./hello 
Hello Worldmac:test mike$ 

This should work out of the box with the latest Xcode. Have you made sure you are using the latest gcc / Xcode and not having previous path or binaries installed?


Without knowing the build errors, you either are missing a tool or have header issues. In the case of the latter, here is how llvm-gcc issues in geos were overcome: http://trac.osgeo.org/geos/ticket/463.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .