GCC issue at Mountain lion

843 views
Skip to first unread message

ISockGo

unread,
Aug 30, 2012, 10:14:09 PM8/30/12
to golan...@googlegroups.com
Hi,

        I have developed a nice chat server at windows system. Now I bought the new mac pro with mountain lion os X. The xcode I have installed is 4.4 from app store. Now when I am trying to compile my go code on my mac. Getting no gcc error. I think xcode 4.4.1 does not install gcc any more. 

MacBook-Pro:main amitabharya$ go build -a
# runtime/cgo
exec gcc: exec: "gcc": executable file not found in $PATH

Can some one suggest me a better solution for this. Will be great. 

Dave Cheney

unread,
Aug 30, 2012, 10:15:52 PM8/30/12
to ISockGo, golan...@googlegroups.com

ISockGo

unread,
Aug 30, 2012, 10:25:26 PM8/30/12
to golan...@googlegroups.com, ISockGo

I tried to install the prior version of xcode, it installed but after that I was getting the same error, and my mac start acting differently, finder and terninals were not working. So I installed the Xcode 4.3.
Mac port needs command line xocode, and I guess xcode 4.4.1 does not have command line mode, as I tried to install gcc from macports too, but got xcode command line install error.

Dave Cheney

unread,
Aug 30, 2012, 10:29:39 PM8/30/12
to ISockGo, golan...@googlegroups.com
Sorry, to be clear, Xcode 4.3 and above does not come with a command
line gcc compiler by default. You must install it by following the
instructions here
http://guide.macports.org/chunked/installing.xcode.html#installing.xcode.lion.43

The instructions for doing this have also been updated in the Go
documentation, and will be available in the 1.0.3/1.1 releases.

You should only install the version of Xcode that Apple recommend for
your operation system, failure to do so could have catastrophic
effects on your machine. You do not need to install macports to use
Go, their instructions were just the easiest to hand.

Cheers

Dave

minux

unread,
Aug 31, 2012, 3:34:05 AM8/31/12
to ISockGo, golan...@googlegroups.com
On Fri, Aug 31, 2012 at 10:29 AM, Dave Cheney <da...@cheney.net> wrote:
Sorry, to be clear, Xcode 4.3 and above does not come with a command
line gcc compiler by default. You must install it by following the
instructions here
http://guide.macports.org/chunked/installing.xcode.html#installing.xcode.lion.43

The instructions for doing this have also been updated in the Go
documentation, and will be available in the 1.0.3/1.1 releases.

Dave Cheney

unread,
Aug 31, 2012, 3:37:09 AM8/31/12
to minux, ISockGo, golan...@googlegroups.com
Neat, I didn't realize that was still running. 

ISockGo

unread,
Sep 1, 2012, 6:43:06 AM9/1/12
to golan...@googlegroups.com
It's done, thanks buddy. The right way to install xcode command line too (gcc) is:
>> Open Xcode 4.4 >> Xcode menu >> Preferences >> Downloads >> Command line tool :: click Install.

And all set :) enjoy.

Dave Cheney

unread,
Sep 1, 2012, 6:44:59 AM9/1/12
to ISockGo, golan...@googlegroups.com
Thanks. Could I ask you to confirm if these instructions, from
tip.golang.org are also correct.

On OS X, a C compiler is bundled in the command line tools for Xcode,
and you don't need to install the whole Xcode to compile Go. If you
have already installed Xcode 4.3+, you can install command line tools
from the Components tab of the Downloads preferences panel. To verify
you have a working compiler, just invoke gcc in a freshly created
Terminal window, unless you see the "gcc: command not found" error,
you are ready to go.

Daniël de Kok

unread,
Sep 1, 2012, 7:38:20 AM9/1/12
to Dave Cheney, ISockGo, golan...@googlegroups.com
On Aug 31, 2012, at 4:29 AM, Dave Cheney <da...@cheney.net> wrote:
> Sorry, to be clear, Xcode 4.3 and above does not come with a command
> line gcc compiler by default.

Actually, it does come with gcc (llvm-gcc to be accurate), but gcc is in the Xcode bundle. You can use gcc without installing the command-line tools with 'xcrun':

xcrun gcc

I don't know if Go uses anything else, but if not, you could just alias gcc to the command above.

-- Daniël

minux

unread,
Sep 2, 2012, 3:46:16 PM9/2/12
to Daniël de Kok, Dave Cheney, ISockGo, golan...@googlegroups.com
installing the command line tools for Xcode really is necessary.

you might encounter weird errors from llvm-gcc otherwise (at least some header files will be missing),
for example:
and

Daniël de Kok

unread,
Sep 3, 2012, 7:06:22 AM9/3/12
to minux, Dave Cheney, ISockGo, golan...@googlegroups.com
Both building of a package using cgo and go itself works for me:

---
% which gcc
gcc not found
exec gcc: exec: "gcc": executable file not found in $PATH
% export PATH=$PATH:$(xcode-select --print-path)/usr/bin
% which gcc
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc
% go build
%
---

Or go tip:

---
%  export PATH=$PATH:$(xcode-select --print-path)/usr/bin
% cd ~/sw/go/src
% sh all.bash
# Building C bootstrap tool.
cmd/dist
[…]
ALL TESTS PASSED

---
Installed Go for darwin/amd64 in /Users/daniel/sw/go
Installed commands in /Users/daniel/sw/go/bin
*** You need to add /Users/daniel/sw/go/bin to your PATH.

On OS X the debuggers must be installed setgid procmod.
Read and run ./sudo.bash to install the debuggers.

%
---

minux

unread,
Sep 3, 2012, 9:01:11 AM9/3/12
to Daniël de Kok, Dave Cheney, ISockGo, golan...@googlegroups.com
On Mon, Sep 3, 2012 at 7:06 PM, Daniël de Kok <m...@danieldk.eu> wrote:
Both building of a package using cgo and go itself works for me:
the result is highly dependent on the xcode version so we can't advise
people to use gcc under /Applications/Xcode.app/Contents/Developer/usr/bin/
Reply all
Reply to author
Forward
0 new messages