MATLAB: When I try to run the MEX -SETUP command from within MATLAB 7.1 (R14SP3), why do I receive errors

MATLAB

I have installed MATLAB into a folder that has 'bin' in its path (for example, C:/_virdrv_E/bin/matlabR14sp3). When I try to execute MEX -SETUP, I receive the following errors
Can't locate mexsetup.pm in @INC (@INC contains:
C:\_virdrv_E/sys/perl/win32/lib C:\_virdrv_E/sys/perl/win32/site/lib
C:/_virdrv_E/bin/matlabR14sp3/sys/perl/win32/lib
C:/_virdrv_E/bin/matlabR14sp3/sys/perl/win32/site/lib . C:\_virdrv_E/bin)
at
C:\_virdrv_E\bin\matlabR14sp3\bin\mex.pl line 203.
BEGIN failed--compilation aborted at
C:\_virdrv_E\bin\matlabR14sp3\bin\mex.pl line 203.
??? Error using ==> mex
Unable to complete successfully

Best Answer

This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
There is a bug in MATLAB 7.1 (R14SP3) in the way that MATLAB handles installed directories that have 'bin' in their path. To work around this issue, follow the steps given below.
In $MATLABROOT\bin (where $MATLABROOT is the folder in which you installed MATLAB), open 'mex.pl' and change the following lines (160 - 162)
if ($f =~ s%^bin[\\/].*%%) {
$f = '.';
} elsif ($f =~ s%[\\/]bin[\\/].*%%) {
to
if ($f =~ s%^bin[\\/]mex.pl$%%) {
$f = '.';
} elsif ($f =~ s%[\\/]bin[\\/]mex.pl$%%) {
Save the file, then close and restart MATLAB.