sucasa
sucasa

Reputation: 371

GCC in Mac vs GCC in linux

I have read countless threads saying that gcc in in the Xcode directory blah blah. I know its there. I can see it. But I dont want to have to know its there and I don't want to have to a) run XCode or b)edit my c programs from /Developer/usr/bin

I want to compile c and c++ programs in ANSI C from the command line and from ANY directory of my choosing similar to how I do it in linux.

ie: gcc -o foo foo.c

then run ./foo

Is this possible in OSX lion or later?

Upvotes: 1

Views: 2287

Answers (3)

Ned Deily
Ned Deily

Reputation: 85055

In Xcode 3.2.6, you need to install the UNIX Development component using the Xcode 3 installer package. That will install the necessary links and header files in /usr and /System/Library. See the About Xcode 3.2.6 document included on the installer dmg or downloadable from the Apple Developer site (an unofficial copy is on the web here).

In the most recent versions of Xcode 4, the Command Line Tools component is installed using Xcode.app itself as others have described.

Upvotes: 0

Pete Becker
Pete Becker

Reputation: 76345

In Xcode's options panel, select "Downloads", and click the "Components" tab. Select "install" next to "Command line tools". That will install them in the usual Unix locations.

Upvotes: 6

tomahh
tomahh

Reputation: 13661

Yes. Depending on your shell, export or setenv (whether you are on bash or tcsh) the PATH variable with your path to gcc.

Upvotes: 0

Related Questions