Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
    
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 '11 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! –  Derek Adair Sep 21 '11 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 '11 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
/usr/bin/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
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
mac:~ mike$ mkdir /tmp/test
mac:~ mike$ cat > /tmp/test/hello.c << EOF
/* Hello World program */

#include<stdio.h>

main()
{
    printf("Hello World");

}
EOF
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?

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.