Using vl_feat on 64-bit Linux with 32-bit Matlab

A lot of very good computer vision and machine learning libraries are written for use in Matlab.
While Matlab has some advantages, I am more of a python man myself.
I am a big fan of the vlfeat library by  Andrea Vedaldi and Brian Fulkerson.
It is written for use in Matlab but there are some Python bindings provided by Mikael Rousson.
Sadly they do not support all of vlfeat's great features.
So today I wanted to make some more of vlfeat's functionality available in Python.
For that, I first had to understand their Matlab interface.
But when I tried to compile vlfeat I ran into some difficulties. The main problem is that the student version of Matlab is provided only in a 32bit version.
But the Linux on my box is 64 bit.
So here the journey begins.

I am using Ubuntu but I guess the steps are quite similar for other distributions.
First of all, you really have to convince mex to compile for 32bit.
So in the Makefile under Linux-32 set

MEX_FLAGS       += -lm -glnx86
MEX_CFLAGS      += -m32
CFLAGS          += -m32

You'll need the package libc6-dev-i386 so do a quick
sudo apt-get install libc6-dev-i386.

Then I was stranded for a while but then found a very helpful blog entry.

So I added
DLL_CFLAGS      += -L<matlabpath>/sys/os/glnx86
MEX_LDFLAGS     += -L<matlabpath>/sys/os/glnx86

and created symlinks

ln -s <matlabpath>/sys/os/glnx86/libstdc++.so.6 \
 <matlabpath>/sys/os/glnx86/libstdc++.so
ln -s <matlabpath>/sys/os/glnx86/libgcc_c++.so.6 \
<matlabpath>/sys/os/glnx86/libgcc_c++.so

Hours later I found:
sudo apt-get install gcc-4.3-multilib

now you can simply make everything with
make ARCH=glx

... and it works!



Comments

Popular posts from this blog

Machine Learning Cheat Sheet (for scikit-learn)

A Wordcloud in Python

MNIST for ever....

Python things you never need: Empty lambda functions