Bug when compiling Mex-files

Ones might encounters problems from compilers when trying to compile MEX files. Assume that you are in Linux, with installed GCC/G++ 4.x and MATLAB R2009x or R2010a. The machine can announces that some libs are absent, i.e. libstdcXXX but the fact is that you already install everything! Okay, the problem is just that there are small problems in the configuration file mexopts.sh, the bash file mentions everything about OS environment for MATLAB. By default, Mathworks encapsulates compilers with Matlab versions, and this compiler version soon to be outdated from the regular update of compiler, i.e. GCC. So, it might cause version conflict when MATLAB tries to find an exact compiler having version XYZ while your machine just have version ZYZ.01 which is more recent.

The solution for this is quite simple. You do not need to create any further symbolic links. Just go into your home directory by typing cd ~; then cd .matlab; then cd R20XXX; then open file mexopts.sh and start modifying.

Depending on your machine which is glnx86 or glnxa64, you must change the lines CC and CXX from gcc-x.xx.x to gcc, and g++-x.xx.x to g++. That’s it! Save it and enjoy Mex files.

Remark: every time you call mex -setup, this file is overrided, then you have to do this stuff again.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.