Posts Tagged ‘Linux’

Cross compiling for i386 from x64 Ubuntu

January 8th, 2011 Comments off

I’ve recently been playing with making programs using Qt and c++, overall I’ve been very happy with it, it’s a nice clean API and very nice to work with. I do most of my development on either my desktop machine or my laptop, both of these run the 64-bit version of Ubuntu Maverick Meerkat. I also have a Acer Aspire Revo, running Ubuntu Maverick Meerkat but this computer is running the 32-bit version. I wanted to get some of my Qt programs running on the Revo but didn’t want to install all the development packages and compile on there (it’s a little slow for compiling code and the screen on my main machine is nicer :-D), so I set about working out how to cross compile my applications to run on 32 bit linux from 64 bit.

The easiest way to do it seems to be using pbuilder to create a 32 bit chroot environment, install all the development packages in there and then compile there. So how do we go about doing that? Well here’s some simple instructions…

First of all we need to install pbuilder and it’s dependencies so first of all run…

sudo apt-get install pbuilder

Now we want to create the 32 bit chroot environment…

sudo pbuilder create --debootstrapopts --arch --debootstrapopts i386

This takes a while to create and requires the downloading and installing of a number of packages. Once this is complete the chroot environment will be setup. We now want to login to the environment and install the extra packages needed to build our application. By default when you exit pbuilder sets the chroot environment back to how it was when you entered, as we don’t want to have to install these packages every time we go in we add an extra parameter to tell it to save any changes we’ve made when we exit.

sudo pbuilder login --save-after-exec

Now we’re in the chroot environment we’ll install the packages needed for development, I needed a couple of packages from universe so enabled it with…

echo "deb maverick universe" >> /etc/apt/sources.list
apt-get update

As I was playing with building 32bit .deb files for my applications that use qt-webkit and vlc I installed the following packages (along with some extras like subversion, vim and openssh-client for convenience) with apt-get…

apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot lintian pbuilder libvlc-dev libqtwebkit-dev vim openssh-client subversion

Once this completed I made a couple of other changes that I wanted to persist between chroot sessions (copying in gpg keys, etc) and then exited the chroot environment with…


This should take a little while as the system compresses the chroot environment so the changes you made persist between sessions. Now whenever you want to go into the chroot to compile just run…

sudo pbuilder login

Incidentally, if you want a good simple tutorial on createing .deb files you wont go wrong looking at this one.


May 28th, 2007 Comments off

A while has passed (as usual) since I last updated this website and a lot has changed in my life. My girlfriend of 7 years and I have split up, though in a very amicable way. I moved out of my flat in Poole and back in with my Parents at the end of January though next weekend I will be moving up to London to be with all my friends and working in the London Office.

As for my projects… not a lot has happened… I’ve started some… stopped working on some and currently thinking about new ones.

As I’ll be moving back and forth between the London and Poole office I thought it was time I had a go at Linux on my laptop and finally fixed a load of issues with it. I’ve finally managed to get the onboard network card working, the wireless is working though NetworkManager wont connect. The only functionality that I’ve had to disable is the MMC Reader as whenever I load the module the whole system hangs. It’s similar to the problems with the network card though there are no settings to change in the kernel. Not a huge issue though… To read my latest guide to my laptop visit this post.

Hopefully once I’ve moved up to London I’ll be able to start playing with XNA and start making games on the XBox360… it’s a nice thought anyway…

Tags: ,

Re-ordering Hard Drive Partitions

October 16th, 2005 Comments off

I’ve been getting more and more annoyed with my Windows box recently… it keeps on crashing and is just going slower and slower. Over the last couple of weeks I’ve noticed that none of the work I do is specifically for Windows… most of it is on servers, so I decided to install Linux on there.

Friday evening I took my machine home, resized my main windows partition and created a load of extra partitions. The partitions under Linux are numbered in the order created, not the order they exist on the hard drive. So my partitions were not in the following order on the disk…

  1. 30Mb Boot Partition – /dev/hda2
  2. 25GB Windows Partition – /dev/hda1
  3. 1GB Swap Partition – /dev/hda3
  4. 10GB Root Partition – /dev/hda4
  5. 14GB Shared (FAT32) Partition – /dev/hda5

Now being the really anal guy I am I wanted my partitions to be numbered as they exist on the hard drive… basically I wanted /boot to be hda1 and windows to be hda2. So I booted up a gentoo live CD, ran fdisk on the disk and used the f command (under advanced options) to re-order the disks… Excellent nice and simple… or not…

Next time I tried to boot windows up Windows came up with some helpful error message saying it couldn’t find some dll or something… After a couple of seconds of crapping my pants… convinced I’d just destroyed my windows partition and was going to have to re-install windows I thought about why this had happened…

It all comes down to the boot.ini file. This file is hidden in the system root (usually c:) and looks something like this…

[boot loader]
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS=”Microsoft Windows XP Professional” /noexecute=optin /fastdetect

The important part is the partition(1) section… for some reason partitions are indexed from 1 unlike the rest of the items which are indexed from 0. All I had to do was change that to partition(2) (as it was hda2) and Windows started booting fine…

Hopefully this information will be useful if anyone else has the same problem.

Tags: ,