How to compile 32-bit mex using a 64-bit system

First make sure Matlab is installed in both architectures glnx86 and glnxa64 For cross compilation to work make sure to

sudo apt-get install g++-multilib libc6-dev-i386

run mex ARCH=glnx86 -v file.c make sure that the lib shows up correctly If it is still listed as glnx64 edit Matlab/bin/mex file and move get_arch call to be after the end of command line parsing (case "$1" in...)

Matlab starts with java Locking assertion failure and a backtrace

First find out what your default java is:

update-alternatives --display java | grep link

then edit .bashrc and add


where path is what you saw from update-altenatives, without the trailing /bin/java now either set it manually for the current session or relogin for MATLAB_JAVA to take effect.

@Troubleshooting @Matlab

@HowTo @Matlab