These instructions explain how to compile VLFeat on your own. This can be useful to customize or contribute to VLFeat, but it is otherwise not necessary (use the binary package instead).

Compiling on Unix

For UNIX based platforms (Mac OS X and Linux), the library bundles a GNU makefile (Makefile). The makefile tries to auto-detect the environment and automatically configure itself. In most cases, typing make is all it is required to compile everything. If this does not work, please edit the makefile and make the necessary adjustment to the flags.

Mac OS X 10.6 (Snow Leopard), 64-bit, and MATLAB 2009b. MATLAB 2009b for Snow Leopard has added 64 bit mex support and a corresponding extension mexmaci64. VLFeat now supports compiling for this platform, but the architecture must be specified manually when compiling, either like:

MEX=/Applications/MATLAB_R2009b.app/bin/mex ARCH=maci64 NDEBUG=y make
MEX=/Applications/MATLAB_R2009b.app/bin/mex ARCH=maci NDEBUG=y make

Unfortunately, MATLAB 2009b has a bug in inclued the mex script, so if you wish to compile yourself, you will need to modify it. We recommend making a backup before making any changes to this file. To fix the bug, you need to cut this line:

get_arch    # Call $MATLAB/bin/util/arch.sh

and paste it after the processing of options:

...
shift
done

#PASTE get_arch call here
get_arch    # Call $MATLAB/bin/util/arch.sh

if [ $v7_compat -eq 1 ] ; then
fc_flags="$fc_flags -DMX_COMPAT_32"
...

Compiling on Windows

For Windows, the library bundles a NMake makefile (Makefile.mak). In order to use it, you must edit Makefile.mak to adjust the values of a number of configuration variables to match your setup. Once you have done that, start the Visual Studio Command Prompt and type nmake /f Makefile.mak.

For Windows platform, it is also possible to compile just the MATLAB MEX files from within MATLAB (using the vl_compile command). This is meant as an helper for less experienced users that may need to recompile the mex file due to binary incompatibilities with older MATLAB versions.

MATLAB 7.0 and earlier require recompling the MEX files by the provided vl_compile command.

Troubleshooting

syntax error: '=' unexpected:

Use nmake /f Makefile.mak. Without /f, nmake will default to the wrong makefile.

'long' followed by 'long' is illegal:

This error is usually caused by attempting to compile outside of the Visual Studio Command Prompt.