This is less a bug report, more just creating a paper trail in hopes the next person doesn't also accidentally lose a day to library errors.
April 27th, 2026: edited to reflect feedback from @kilir and @vtvivian
If you are:
- a Linux user
- using a newer version of MATLAB (2025b for me)
- using MTEX 6.1 to automatically download the correct .mexa64 files for you,
You might run into the same issue I did, where jcvoronoi_mex gives a Failure result during MTEX's install, and then a variation of the following error when running calcGrains:
checking: jcvoronoi_mex.mexa64 failed
--> [Invalid MEX-file '/path/to/mtex/mtex-6.1.0/mex/jcvoronoi_mex.mexa64': /path/to/matlab/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by jcvoronoi_mex.mexa64)]
This (I believe?) is because jcvoronoi is the only MTEX mex that is compiled from .cpp, and the version it's compiled with needs to match the libstdc++.so.6 INSIDE THE MATLAB INSTALL.
The three solutions that have worked for me:
Option A: soft link your own libstdc++.so.6
Inside the system terminal (not the MATLAB one), find where the MATLAB libstdc++.so.6 file is (usually sys/os/glnx64), move it somewhere else as a backup, and replace it with a softlink to your local library.
cd <matlabroot>/sys/os/glnxa64
sudo mkdir old_libs
sudo mv libstdc++.so.6* old_libs
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6
# (Adjust paths as needed)
Option B: Recompile the relevant mex
Delete mtext-6.1.0/mex/jcvoronoi_mex.mexa64, get a mex builder if you don't already have one via
sudo apt install build-essential
and run mex_install from matlab.
Option C: Add the system library to matlab
Add the following line to your .bashrc profile:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
# (Adjust path as needed)
I'll also add, as a Linux user, the mex changes in 6.1.0 have been a huge time saver and the above has been the only real problem I've seen so far. Thank you for the hard work, it makes my life considerably easier.
This is less a bug report, more just creating a paper trail in hopes the next person doesn't also accidentally lose a day to library errors.
April 27th, 2026: edited to reflect feedback from @kilir and @vtvivian
If you are:
You might run into the same issue I did, where jcvoronoi_mex gives a
Failureresult during MTEX's install, and then a variation of the following error when running calcGrains:This (I believe?) is because jcvoronoi is the only MTEX mex that is compiled from .cpp, and the version it's compiled with needs to match the libstdc++.so.6 INSIDE THE MATLAB INSTALL.
The three solutions that have worked for me:
Option A: soft link your own libstdc++.so.6
Inside the system terminal (not the MATLAB one), find where the MATLAB libstdc++.so.6 file is (usually sys/os/glnx64), move it somewhere else as a backup, and replace it with a softlink to your local library.
Option B: Recompile the relevant mex
Delete mtext-6.1.0/mex/jcvoronoi_mex.mexa64, get a mex builder if you don't already have one via
sudo apt install build-essentialand run
mex_installfrom matlab.Option C: Add the system library to matlab
Add the following line to your
.bashrcprofile:I'll also add, as a Linux user, the mex changes in 6.1.0 have been a huge time saver and the above has been the only real problem I've seen so far. Thank you for the hard work, it makes my life considerably easier.