After 2+ years running Lucid Lynx I decided to upgrade to a recent version of Ubuntu, Oneiric Ocelot. I tend to stay behind the curve a bit to give early adopters the opportunity to work out most of the kinks. In the past I have been burned in my haste to stay on the bleeding edge. Being 1-2 versions behind seems to work well to avoid any potential issues. Upgrading to Oneiric was mostly uneventful and I didn’t notice any compatibility issues until I tried building some code against an older version of GCC I previously built in Lucid. I encountered the following error anytime I tried to compile using the
/usr/bin/ld: cannot find crt1.o: No such file or directory /usr/bin/ld: cannot find crti.o: No such file or directory collect2: ld returned 1 exit status
It turns out that recent Debian releases and their derivatives have transitioned to multiarch support. The idea is to allow seamless support of binaries built for different architectures, related or not, to live concurrently on the same system. In theory it should be more portable than the lib32/lib64 conventions of the past. Unfortunately, the side effect is that some applications depending on the old paths are now woefully broken. The good news is a simple workaround will allow older GCC versions to build without issue. Building an older version of GCC is still straightforward when following the instructions in my previous post, applying the necessary patches and running the following command to fix-up the compiler paths:
sed -i 's|\.\./lib64|x86_64-linux-gnu|' gcc-<version>/gcc/config/i386/t-linux64
For example, the following will build and install GCC 4.7.0 from source to a custom prefix:
tar xzf gcc-4.7.0.tar.gz sed -i 's|\.\./lib64|x86_64-linux-gnu|' gcc-4.7.0/gcc/config/i386/t-linux64 mkdir ../gcc-4.7.0-objdir cd ../gcc-4.7.0-objdir ../gcc-4.7.0/configure --prefix=/opt/x86_64/gcc/gcc-4.7.0 --enable-languages=c,c++ make make install
Voila! Older GCC versions should now build and compile applications without issue.