Thursday, October 24, 2013

Golang, cgo, and XCode 5

TL;DR: Don't. Stick with XCode 4 for now.

I don't know much about developing on Mac. I may also be a moron. I'm a Linux guy and can at least make the claim that I'm a programmer. I'm definitely comfortable with command line tools and relatively uncomfortable with IDEs.

I've been working on a video game project on Mac in go, using go-gl. The go-gl suite is a set of thin wrappers around C opengl libraries. As such, it depends on local C compilers and the cgo compiler. My libraries are installed via MacPorts which required installing XCode and its command line tools. Those command line tools also provide tools and headers that will be used by cgo to compile go code and C code that are linked together.

When XCode 5 came out it showed up as a regular upgrade which I followed. I dutifully installed the new command line tools. I later found that I could no longer compile my game code. Any code that didn't require go-gl was working fine.

Eventually I found that the issue was that XCode 5 no longer includes GCC. I eventually figured out that if I install gcc47 from MacPorts, prefixed builds with CC="gcc-mp-4.7", built go from source, then prefixed all my go get and go run commands wit the above CC envvar I could get it to work. However, it would no longer produce static libraries for the opengl wrappers and my compiles that were previously instantaneous where now taking on the order of 10 seconds.

I upgraded to Mavericks today and my XCode along with it. It didn't help. Being frustrated I did more digging and found that if I went back to XCode 4 things should be fine again. I ripped out XCode 5, navigated the Apple Web Maze to find XCode 4, download it, grab the command line tools, etc. Seems to work now the way it used to.

Except, MacPorts is broken. Mavericks doesn't have /usr/bin/gnutar so I have to ininstall MacPorts. There's no binary package for Mavericks so I have to do a source install. That was at least painless. This gripe has nothing to do with go, of course.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.