Skip to content

Fixing jcvoronoi_mex build failure on ubuntu in MTEX 6.1 #2482

Description

@argerlt

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:

  1. a Linux user
  2. using a newer version of MATLAB (2025b for me)
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions