MATLAB: Do I receive the error “The system cannot find the path specified” with MATLAB 7.14 (R2012a) when I try to use MEX.GETCOM​PILERCONFI​GURATIONS or LOADLIBRARY

lccinstalldirlengthMATLABname

I am using MATLAB 7.14 (R2012a) 32-bits on a Windows machine. I have set up the LCC compiler by running the following command in MATLAB:
>> mex -setup
I can MEX timestwo.c without any issues.
When I try to load a shared library with
>> loadlibrary('mylibrary.dll', 'myheader.h')
or try to get the chosen compiler with
>> mex.getCompilerConfigurations
I get the following error: ERROR: Warning: ''Test' is not recognized as an internal or external command, operable program or batch file. LCCINSTALLDIR' exceeds MATLAB's maximum name length of 63 characters and has been truncated to ''Test' is not recognized as an internal or external command, op'. > In CompilerConfigurationFactory>CompilerConfigurationFactory.determineLocation at 268 In CompilerConfigurationFactory>CompilerConfigurationFactory.process at 127 In getCompilerConfigurations at 56 Reference to non-existent field ''Test' is not recognized as an internal or external command, op'. Error in mex.CompilerConfigurationFactory/determineLocation (line 268) location = detailStruct.(outputValue); Error in mex.CompilerConfigurationFactory/process (line 127) basicStructArray(numberOfLangs).Location = determineLocation(obj, storageLocations{index}, basicStructArray, detailsStruct); Error in mex.getCompilerConfigurations (line 56) compConfig = process(ccF);

Best Answer

This is a bug in MATLAB 7.14 (R2012a), related to how MATLAB is interpreting the system path when calling LOADLIBRARY or MEX.GETCOMPILERCONFIGURATIONS.
The reason for the behavior is a "&" character, or a space, in the systems "Path" values, e.g. when the path includes a folder such as:
C:\Test&Measurement
or
C:\Common Files
To verify the current system path, use:
>> getenv('path')
To work around this issue, modify your system path with one of the following options:
1- Use double quotation marks around the specific folder in the system path which contains the "&" character or the space: "C:\Test&Measurement"
or
2- Remove the folder from the system path (if possible).