Search code examples
octavemexvlfeat

Compiling vlfeat mex in octave: undefined symbol


I hope this question is not to specific. I am trying to compile the vlfeat library for octave 3.6.2.

It compiles the mex-files without errors. But if I execute

vl_setup
vl_demo

i get

error: vl_demo_sift_basic: vl_sift.mex: failed to load: vl_sift.mex: undefined symbol: vl_sift_process_next_octave

If I use octave 3.4.3 instead, the mex file loads without errors. (But there are other errors later because of matlab functions which are not implemented yet in this version of octave.)

I have no idea how I could start investigating this problem. What could be the reason for such an error message? Or what can I do to further investigate this problem?

Update: I did some more research. But I am not very familiar with the process of linking and compiling.

Using ldd I can see that the vlfeat shared library does not show up in the list. Using nm the symbols appear as 'U' for undefined. But I think the library should be linked. The problem is with all the mex files. Here is one example of how the files are compiled. As far as I can see, the library is linked to the mex-file.

CFLAGS="-std=c99 -Wall -Wextra -Wno-unused-function -Wno-long-long -Wno-variadic-macros    -DNDEBUG -O3  -I./toolbox" \
CXXFLAGS="" \
LDFLAGS=" -Wl,--rpath,\$ORIGIN/ -Wl,--as-needed -lpthread -lm -Lbin/glnxa64 -lvl" \
 mkoctfile \
       --mex  \
       "./toolbox/misc/vl_version.c" --output "toolbox/mex/octave/vl_version.mex"

Solution

  • I met same problem. The following works:

    1. Make sure that missing symbol "vl_sift_process_next_octave exists" in vlfeat dynamic library - libvl.so - by "nm libvl.so | grep vl_sift_process_next_octave". If it is not the case, you shoud rebuld vlfeat.

    2. If it does, check that annoying mex file vl_sift.mex refers libvl.so correctly by "readelf -d vl_sift.mex". There appear libvl.so entry in dynamic section or rebuild mex file specifying explicitly missing so by "mkoctfile --mex -lvl ...".

    3. Now a final step is left. The "libvl.so" should be visible to octave. Use ldconfig to add libvl.so into so cache and test whether it exists in the cache by "ldconfig -p | grep libvl.so". That is all.