Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Invalid MEX-file error in Matlab

📅 2016-Jan-18 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cpp, error, matlab ⬩ 📚 Archive

Problem

Running a Matlab script threw this error:

Invalid MEX-file '/home/joe/do_work.mexa64':/usr/local/matlabR2014b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version 'GLIBCXX_3.4.19' not found (required by /home/joe/do_work.mexa64).

This error is surprising since do_work.mexa64 was built using Matlab using the same system and same environment settings.

Solution

There is a difference in the glib version between the compiled and running environment. When the do_work.mexa64 was built, the libstdc++.so.6 from /usr/lib/x86_64-linux-gnu/ was used since it was first in LD_LIBRARY_PATH. However, when the script is run by Matlab, it picks up its own libstdc++.so.6 file as explained here!

A simple solution to this problem is to remove or rename the Matlab version of libstdc++.so.6, so that it is not picked up.

Tried with: Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧