CGO Compilation for Mac OS X 10.9 Mavericks

After upgrade to Mac OSX 10.9 you Cgo package will not be compiled successfully if you use the default clang compiler. For example, if you install gozmq on Mavericks you’ll get following error:

$ go get -tags zmq_3_x

clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types'

I tried apple-gcc4.2 installed from homebrew but also failed:

$ GCC=gcc-4.2 go get -tags zmq_3_x

clang: warning: argument unused during compilation: '-pthread'

clang: error: no such file or directory: 'libgcc.a'

The solution is to download and install pre-built gcc package GCC-10.7-v2.pkg from osx-gcc-installer. Then you can install the GO package as below:

$ GCC=gcc-4.2 go get -tags zmq_3_x

It works for other Cgo package like goejdb as well.

Good luck and have fun!