Skip to content

Instantly share code, notes, and snippets.

@nddrylliog
Last active December 21, 2015 19:39
Show Gist options
  • Save nddrylliog/6355654 to your computer and use it in GitHub Desktop.
Save nddrylliog/6355654 to your computer and use it in GitHub Desktop.
Linux / Ubuntu 32-bit and 64-bit build / configure scripts
#!/bin/bash
export PREFIX="/home/amos/Dev/prefix32"
export CPPFLAGS="-I${PREFIX}/include"
export CFLAGS="-m32"
export CXXFLAGS="-m32"
export LDFLAGS="-m32 -L${PREFIX}/lib"
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
"$@" --prefix=${PREFIX}
#!/bin/bash
export PREFIX="/home/amos/Dev/prefix64"
export CPPFLAGS="-I${PREFIX}/include"
export CFLAGS="-m64"
export CXXFLAGS="-m64"
export LDFLAGS="-m64 -L${PREFIX}/lib"
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
"$@" --prefix=${PREFIX}

IMPORTANT NOTE: don't bother with this... a chroot is the way to go, actually.

So, Linux distros are all the same - they pretend they can do multilib and then they bail on ya. Cf. ArchLinux, Gentoo, Debian, Ubuntu.. and don't get me started on ia32-libs.

So, compile your own libs! It's like Homebrew except double the fun cause you get to do cool stuff by hand.

The scripts above contain some paths that need to be adjusted. They're not meant for widespread use but hey, I like to keep my own stuff neat and tidy so I can find it later, so there you go.

Making your prefixes

I put all my development stuff in ~/Dev/. From there I have ~/Dev/prefix32 and ~/Dev/prefix64 for 32-bit and 64-bit libs.

auto-tools (./configure) projects

Never ever build projects in tree, especially auto-tools one. The general process goes like this:

  • download and extract sources to ~/Dev/somelib/
  • mkdir ~/Dev/somelib-build32 ~/Dev/somelib-build64

Build 32-bit version

  • cd ~/Dev/somelib-build32
  • 32configure ../Dev/somelib/configure
  • make -j7
  • make install

Same for 64-bit version and congrats!

Copying libs locally

The flag you want is '-rpath', pass it to the linker via rock using +-Wl,-rpath=bin/libs64 etc.

To know which libs to copy in bin/libs64, do something like:

for l in $(ldd johnq64 | egrep "(/usr/lib/)|(prefix64)" | cut -d ' ' -f 3 | egrep -v "lib(X|x|GL|gl|drm)" | tr '\n' ' '); do cp $l libs64/; done

Basically: we want to know, among the dynamic dependencies of johnq64, stuff that's in /usr/lib or $HOME/Dev/prefix64 but not anything that starts in libX, libx, libGL, libgl, or libdrm and then we want to copy them to libs64/.

To check that it went well:

ldd bin/johnq64 | grep libs64

Should give something like:

        libSDL2-2.0.so.0 => bin/libs64/libSDL2-2.0.so.0 (0x00007fc6fa615000)
        libSDL2_mixer-2.0.so.0 => bin/libs64/libSDL2_mixer-2.0.so.0 (0x00007fc6f9ee0000)
        libmxml.so.1 => bin/libs64/libmxml.so.1 (0x00007fc6f9cd3000)
        libfreetype.so.6 => bin/libs64/libfreetype.so.6 (0x00007fc6f9a37000)
        libyaml-0.so.2 => bin/libs64/libyaml-0.so.2 (0x00007fc6f9815000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment