vlfeat / vlfeat

An open library of computer vision algorithms

Home Page:http://vlfeat.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Building VLFeat on Mac M1 for ARM Architecture

josefgrunig opened this issue · comments

Hi, I am trying to build VLFeat on a Mac M1 machine with make but it seems that the Architecture is not supported.
Any hint how I can get it working, by editing the makefile?

** Unknown host architecture 'Darwin arm64'. This identifier
** was obtained by running 'uname -sm'. Edit the Makefile 
** to add the appropriate configuration.

I was able to build VLFeat manually.

First you need to build the libvl.dylib dynamic library (note we are disabling AVX, SSE2 since it is not on Apple Silicon):

$ cd {project_root}/vl
$ gcc -dynamiclib -fPIC -DVL_DISABLE_AVX -DVL_DISABLE_SSE2 -o libvl.dylib *.c

Then you can build C/C++ programs using the library. For example, the tools in the {project_root}/src.

$ cd {project_root}/src
$ gcc -I{project_root} -L{project_root}/vl -lvl aib.c -o aib
$ ./aib
./aib                                                                                                                                                                                ─╯
Pic = [0.681300 0.302800 0.821600 ; ...
0.379500 0.541700 0.644900 ; ...
0.831800 0.150900 0.818000 ; ...
0.502800 0.697900 0.660200 ; ...
0.709500 0.378400 0.342000 ; ...
0.428900 0.860000 0.289700 ; ...
0.304600 0.853700 0.341200 ; ...
0.189700 0.593600 0.534100 ; ...
0.193400 0.496600 0.727100 ; ...
0.682200 0.899800 0.309300 ; ...
];
AIB starting
0 => 13
1 => 10
2 => 13
3 => 10
4 => 16
5 => 11
6 => 11
7 => 12
8 => 12
9 => 14
10 => 15
11 => 14
12 => 15
13 => 16
14 => 17
15 => 17
16 => 18
17 => 18
18 => 0
IB done

Make sure libvl.dylib is in the same directory or is in the DYLD_LIBRARY_PATH environment variable.

The compiler I used:

gcc --version                                                                                                                                                                        ─╯
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Pretty sure the project can be converted to a nice and simple CMake project. Maybe I will do it one day.

There's something wrong with basic vl_* data types when on Apple Silicon.

Running sift utility on a sample PGM file, I am getting obviously wrong image size information:

./sift -v hi.pgm                                                                                                                                                                     ─╯
sift: <== 'hi.pgm'
sift: image is 9751594488 by 9751594912 pixels
sift: err: Could not allocate enough memory. (2)

My hi.pgm image file size is 30 x 15 pixels.