Home / blog / 8
Hello Anon, Login?

I just spent a day fighting against this so here is the solution I ended up using.

Problem: I want to build a linux binary that stands a chance of "just working" for as many linux users as possible.

Possibly one of the ways of doing this seems to be, build against a release from a couple of years ago. That way we don't gain any dependencies on new version of libraries for people who are slow to upgrade. Instead we get dependency problems for people who are fast to upgrade, these problems however tend to be fixable and common.


chroot to the rescue, unfortunately most people that want to chroot are package manager type people rather than normal folk. Which means I tried a few examples without much luck.

So here is my example, which works for me but probably won't for you.

mk-sbuild seems OK at building a basic environment so we use that initially to deal with all the basic setup. The rest of the sbuild commands are where it fell apart for me.

mk-sbuild precise

This chugs away setting stuff up somewhere like var/lib/schroot/chroots/precise-i386

Luckily I keep my home on a separate partition to make for easier os upgrades so I can do the following to import it into that environment

mount -o bind /home /var/lib/schroot/chroots/precise-i386/home

Now we can just chroot into that like so, then cd into our home and build

sudo chroot /var/lib/schroot/chroots/precise-i386

If you dont want to be root then "adduser myname" and "su myname" will help you out and possibly even match you user id.

I can't believe this all took a day of painful failure to work out.

I also don't even know if this is useful :) Maybe the best bet is static linking and writing a lazy linking stub for libgl and libudev which are the static sticking points for me. However that is more work and may not help.

Also going back in time a few years I find clang is not happy, which is a shame as I'm considering it my main compiler nowadays.

So, a day of possibly no success, hurrah!


PREVNEXT