I’ve gotten apple-gcc42 to install AND compile c++ code. This has been a “long, hard battle,” but i think I’ve finally won. I was “inspired” to take up this challenge after lfranchi, one of the amarok developers, pointed out that one of the build errors we were getting (in amarok 2 for OSX) was due to use of an old compiler. We have gcc 4.0.1 with custom apple patches on OS X. We can install updated versions of gcc, but these are vanilla versions of GNU’s venerable compiler suite. This absence of apple extensions makes it unsuitable for use as a compiler for certain software which requires these extensions. Qt is one (and actually the only) such software which I’ve found requiring these apple-isms. Unfortunately, I actually need Qt for KDE for Amarok. :-) One might think it would be possible to compile Qt w/ apple’s compiler (4.0) then build everything else with 4.2. My half-assed attempt at getting this to work proved unsuccessful. I also didn’t like the idea of mixing software built from compilers whose versions were so far apart. I believe implementations of key features such as visibility tend to differ/change/improve with major releases enough to be incompatable or cause unforseen bugs in software.
But wait, Apple to the rescue! Kind of. The good boys and girls at apple have been working on an apple-ized version of gcc 4.2. Macports, my software build/maintenance/packaging system of choice on OS X has a port for this version of gcc, dubbed apple-gcc42. It would seem like problem solved, but not so. Len actually tried it out and it didn’t work. After digging into it further I found that the port didn’t build in support for g++. Well, that’s silly, I thought. I’ll just add it myself. After doing this and getting apple-gcc42 to both build and install successfully I declared total victory and gleefully informed lfranchi of my success. Ah the folly and naïveté of youth. It didn’t actually compile c++ code though.
After a whole lot of trial and error last week I finally got it to almost do something. The only remaining issue I had was that ld couldn’t find -lstdc++. Well I know what that is! It’s libstdc++ of course, the standard c++ library. And I knew why I was getting that error too, apple’s gcc deletes the libstdc++ directory in the builddir. According to the comments in their buildscript, this is done because they install libstdc++ from somewhere else. I looked for a libstdc++ port but alas none was available. I assumed then that I could do something at build/configure time to get ld to recognize where i already had libstdc++ installed (4.0 version). After all if the apple dudes could do it then it was certainly possible. Well after wasting a whole day on irc, the internets and the console and not having anything to show for it I gave up. After all, I had GTA IV to deal with, and lfranchi had already worked around our compile issue in amarok so this was merely an academic exercise at this point.
I hate losing to a computer though. After all, the stupid things only do what you tell them to. We can actually think, we troubleshoot, we solve problems. Then we get the computers to do the bitch work once we figure it all out for them. Really.
So after being encouraged by some other worked I was doing at the rear end of this week, namely making progress on a self-contained amarok.app package, I decided to revisit apple-gcc42 last night. In between sleep, google searches and typing in my password to sudo something miraculous happened. My brain started to work. My compiler (or the linker portion of it) wanted libstdc++, instead of trying to tell it where the library was, why not just give it the library. Sure it’s not elegant, but having been through that whole process with xine-lib, i quite frankly don’t give a hoot about “elegantness” anymore. If it works I’m happy. So it was that I linked libstc++.dylib from its gcc-4.0 home to it’s new location in apple-gcc42-topia. Then I compiled one of my test c++ command line programs I had lying around; and that worked too. Then I compiled some macport c++ packages. They built and installed. Progress had been made. Now I’m in the process of rebuilding all my ports with apple-gcc42. I don’t know if it’s necessary but I’d rather be safe than sorry. The real test however comes when I compile Qt 4.4.0. If that works, I will have deemed this a success. And maybe I’ll even be motivated enough to finished the app package. A little birdie even provided me with some useful scripts that should make it much easier. More on that later though. Maybe.
And I want my cookie.