Installing GCC compiler to usr/local/bin

KBG


Joined
May 13, 2011
Messages
3
Reaction score
0
Points
1
Hi everyone,

I am trying to compile some C code from the terminal, and I am running into trouble. I have installed Xcode, so I have the GCC compiler, but Xcode installs it into /developer/usr/bin. So I used

export PATH=$PATH:/developer/usr/bin

which worked. It found the GCC compiler. Then I had to tell it where my libraries were...so I used

export LIBRARY_PATH=$LIBRARY_PATH:/Developer/SDKs/MacOSX10.6.sdk/usr/lib

which also worked. But then, if I want to use any header files with #include, it doesn't know where to find them, and I don't know how to tell it where they are.

I am trying to compile the infamous "hello world" program:

#include <stdio.h>

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

getch();
}


but I don't know where it is looking for the stdio.h file.


It seems like all of this could be prevented if Xcode would just install GCC into the usr/local/bin folder, which is where I think it should be.

Can anyone tell me how to make this happen? Or do I need to reinstall OS X and specify that I want GCC etc. installed?

Thank you.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
GCC should be symlinked to a version specific binary in /usr/bin. For instance, /usr/bin/gcc is symlinked to /usr/bin/gcc-4.2 on my machine.

If Xcode is installer properly, everything should be linked as it should be. If you execute the following at the command line, what do you get?
Code:
whereis gcc
 
OP
K

KBG


Joined
May 13, 2011
Messages
3
Reaction score
0
Points
1
Ok...never mind.

Well, I re-installed Xcode, and now everything works without my having to redirect paths and such. I don't know why, but it works!
 
OP
K

KBG


Joined
May 13, 2011
Messages
3
Reaction score
0
Points
1
Right, Vansmith, now it says /usr/bin/gcc when I submit

whereis gcc
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top