Search code examples
linuxmatlabgccmexlinker-errors

MATLAB Invalid MEX-file error: missing symbol invalid_argument


I have this problem where MATLAB (R2017a) fails loading a certain MEX-file:

Invalid MEX-file '/home/travis/local/lib/acadosMEX.mexa64': 

Missing symbol '_ZdlPvm' required by '/home/travis/local/lib/acadosMEX.mexa64'
Missing symbol '_ZNSt13runtime_errorC1EPKc' required by '/home/travis/local/lib/acadosMEX.mexa64'
Missing symbol '_ZNSt16invalid_argumentC1EPKc' required by '/home/travis/local/lib/acadosMEX.mexa64'.

Running ldd on that MEX-file gives me

> ldd $HOME/local/lib/acadosMEX.mexa64

linux-vdso.so.1 =>  (0x00007ffe3fab2000)
libmex.so => not found
libmx.so => not found
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9adb90a000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9adb5f8000)
libblas.so.3 => /usr/lib/libblas.so.3 (0x00007f9ad9def000)
libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007f9ad9ac7000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9ad97c1000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9ad93f9000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9ad91e1000)
/lib64/ld-linux-x86-64.so.2 (0x000056477b9a3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9ad8fc3000)
libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f9ad8d84000)

Now if I grep _ZNSt16invalid_argumentC1EPKc:

> nm -D /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep _ZNSt16invalid_argumentC1EPKc
000000000008b520 T _ZNSt16invalid_argumentC1EPKc

so the symbol is definitely there; thus I set my LD_LIBRARY_PATH to point to that directory, i.e. /usr/lib/x86_64-linux-gnu/ (this should not be necessary, right?).

I should also say that I try all of this with g++-5 (g++-6 gives same error), but with g++-4.9 it works as required.

Is all of this the cause that MATLAB does not support g++>=5 (link)? Or is there still some way of making it work?


Solution

  • According to this page, MATLAB 2017a only supports gcc-4.9, not 5 or 6. Recompiling with the supported compiler solved the problem.