Apple gcc 4.2 and Amarok: Journey's end

Posted by Orville Bennett on 23 May 2008
Read time: about 4 minutes

Apple gcc 4.2 and Amarok: Journey's end beginning

The iPhone beta 5 SDK saved me. I finally have a (relatively) trouble-free version of gcc 4.2 with apple patches. Initially I did have some problems with it. It only started working seemlessly after I completely uninstalled Xcode 3.0, rebooted, then installed Xcode 3.1 from the iPhone SDK. Theoretically the two can be installed alongside each other with the iPhone SDK's command line tools being installed over the older version. All I have left to do now is figure out what libraries and other supporting data amarok needs to run so that I can create a .app bundle. Things are shaping up nicely so I'm actually quite optimistic about that. I already have a bundle that runs, but no graphics or sound. That's something at least. ;-) Hopefully I can get this done in a week and pass things over to the logger for automation.

To recap: I used apple-gcc42 from macports to compile most of the kde prerequisites (boost being the notable exception, only worked with gcc 4.0). I modified the portfile and changed the configure.args section to

configure.args  --enable-languages=c,c++,objc,obj-c++ \
                --program-suffix=-apple-4.2 \
                --with-gxx-include-dir=/usr/include/c++/4.0.0 \
                --disable-checking --enable-werror

The following should work as well, and probably only makes a difference if you're on leopard.

configure.args  --enable-languages=c,c++,objc,obj-c++ \
                --program-suffix=-apple-4.2 \
                --with-gxx-include-dir=/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0 \
                --disable-checking --enable-werror

To actually use the compiler by default I installed gcc_select, sudo port install gcc_select, and then created the file /opt/local/etc/select/gcc/apple-gcc42 with the following contents:

/opt/local/bin/gcc-apple-4.2
/opt/local/bin/cpp-apple-4.2
/opt/local/bin/c++-apple-4.2
/opt/local/bin/g++-apple-4.2
-
/opt/local/bin/gcov-apple-4.2
-

Yes, those -'s are important.

Then to ACTIVATE my awesome hack I did

sudo gcc_select apple-gcc42
cd /usr/lib/gcc/
sudo ln -s i686-apple-darwin9 i386-apple-darwin9.2.2

All that, got me a compiler which worked just fine for building ports. KDE was a different beast however. That's where the iPhone SDK came in. I pretty much followed the instructions in the Amarok2 on OSX wiki page (which is a funny thing to say since I wrote it). To utilize gcc 4.2 from the SDK I used the following as the cmake configure command:

CC=/usr/bin/gcc-4.2 CXX=/usr/bin/c++-4.2 cmake -DCMAKE_INSTALL_PREFIX=/opt/kde4 -DCMAKE_BUILD_TYPE=debugfull ..

I hit some issues when compiling phonon from qt 4.4.0 too, but since it doesn't even work I won't bore you with the details.

After that it was smooth sailing until I hit kdelibs. I had to modify two CMakeLists.txt files to get past some errors I encountered. Here's what svn diff said I did:

Index: /Users/orville/kdesvn/trunk/KDE/kdelibs/kinit/CMakeLists.txt
===================================================================
--- /Users/orville/kdesvn/trunk/KDE/kdelibs/kinit/CMakeLists.txt        (revision 810365)
+++ /Users/orville/kdesvn/trunk/KDE/kdelibs/kinit/CMakeLists.txt        (working copy)
@@ -34,7 +34,7 @@
   set(kdeinit_SRCS kinit_win.cpp  )
   set(kdeinit_LIBS kparts psapi)
 else (WIN32)
-  set(kdeinit_SRCS kinit.cpp proctitle.cpp )
+  set(kdeinit_SRCS kinit.cpp proctitle.cpp ../kdecore/kernel/kkernel_mac.cpp)
   set(kdeinit_LIBS kparts)
 endif (WIN32)
Index: /Users/orville/kdesvn/trunk/KDE/kdelibs/kdeui/CMakeLists.txt
===================================================================
--- /Users/orville/kdesvn/trunk/KDE/kdelibs/kdeui/CMakeLists.txt        (revision 810365)
+++ /Users/orville/kdesvn/trunk/KDE/kdelibs/kdeui/CMakeLists.txt        (working copy)
@@ -238,7 +238,7 @@
     set(kdeui_LIB_SRCS ${kdeui_LIB_SRCS} util/kkeyserver_x11.cpp )
 endif (Q_WS_X11)
 if (Q_WS_MAC)
-    set(kdeui_LIB_SRCS ${kdeui_LIB_SRCS} util/kkeyserver_mac.cpp )
+    set(kdeui_LIB_SRCS ${kdeui_LIB_SRCS} util/kkeyserver_mac.cpp ../kdecore/kernel/kkernel_mac.cpp)
 endif (Q_WS_MAC)
 if (Q_WS_WIN)
     set(kdeui_LIB_SRCS ${kdeui_LIB_SRCS} kernel/kapplication_win.cpp )

I disabled nepomuk in kdebase as it was complaining about some soprano stuff. It doesn't work anyway so I couldn't be arsed figuring out what was wrong. I also uninstalled all the files installed by automoc (prerequisite for akonadi) as I suspected it was causing the duplicate symbol errors I was seeing in amarok's build. It was smooth sailing from there on out. Leave comments if you have trouble, I'll probably be able to help. Irc's better though; #amarok on irc.freenode.net.

Why'd I do all this btw? Because gcc 4.0 can't compile code properly from plasma. Amarok uses plasma, which means I need plasma. The things I do for Amarok. It better love me. It better love me hard.