2016-01-14

How to build apitrace 32-bit on Ubuntu 15.10 x64

First, install build tools:

sudo apt-get install build-essential
sudo apt-get install g++-multilib
sudo apt-get install cmake

Then, install needed 32-bit dependencies:

sudo apt-get install libx11-dev:i386
sudo apt-get install libz-dev:i386
sudo apt-get install libpng-dev:i386
sudo apt-get install libdwarf-dev:i386

You are ready to get the source code and build it:

git clone https://github.com/apitrace/apitrace
cd apitrace

cmake \
    -H. -Bbuild32 \
    -DCMAKE_C_FLAGS=-m32 \
    -DCMAKE_CXX_FLAGS=-m32 \
    -DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib32 \
    -DENABLE_GUI=FALSE
make -C build32

Now you can run a test:

build32/apitrace trace path/to/my-opengl-app32

You will get a file called my-opengl-app32.trace. However, if you try to replay it with the installed version of qapitrace from the Ubuntu repository, you will get an error:

qapitrace path/to/my-opengl-app32.trace

Loading  :  "my-opengl-app32.trace" 
error: unsupported trace format version 5
error: failed to open  "my-opengl-app32.trace"

So it looks like we also need to build a fresh new qapitrace. This time, we can go back to the 64-bit world:

Get again the dependencies, but this time it will be the 64-bit versions:

sudo apt-get install libx11-dev
sudo apt-get install libz-dev
sudo apt-get install libpng-dev
sudo apt-get install libdwarf-dev

And get the Qt dependencies:

sudo apt-get install qtbase5-dev libqt5webkit5-dev

You are now ready to build:

cmake -H. -Bbuild64
make -C build64

And open your trace file:

build64/qapitrace path/to/my-opengl-app32.trace