MATLAB: Do I get an invalid MSVC environment variable build error with xPC Target 2.9 (R2006a), even though the options file is set correctly

compilerreal timeSimulink Real-Timestudiovisualworkshop

After using
mex -setup
to set up the compiler path, the path setting in XPCEXPLR is not updated. It remains set on the default 'c:\microsoft visual studio'.
When I building my model, I get the following error:
Error using ==> rtw\private\issue_inv_comp_env_val_error
Invalid setting for environment variable MSDevDir or DevEnvDir.
the setting is: 'c:\microsoft visual studio'
You can verify the setting by checking for the existence of:
%DevEnvDir%\..\tools\vsvars32.bat (for Visual C/C++ 7.1)
%MSDevDir%\..\..\vc98\bin\vcvars32.bat (for Visual C/C++ 6.0)
You must define MSDevDir or DevEnvDir to be:
set %DevEnvDir%=<VisualRoot>\common7\ide (for Visual C/C++ 7.1)
set %MSDevDir%=<VisualRoot>\common\msdev98 (for Visual C/C++ 6.0)
This error may be due to an invalid preference file:
C:\Documents and Settings\Administrator\Application
Data\MathWorks\MATLAB\R2006a\mexopts.bat
Please run "mex -setup" at the MATLAB prompt to correct.
The options file is correct, only the path in xPC Explorer is wrong. This message can safely be ignored.

Best Answer

The documenation has been updated for Release 2008b (R2008b). For previous product releases, read below:
This is expected behavior in MATLAB 7.2 (R2006a); the 'mex -setup' command does not update the xPC Target Explorer options file.
You must use the xPC Target Explorer (xpcexplr) to set the path to the compiler, as follows:
1. Type the following at the MATLAB command prompt
xpcexplr
2. Enter the path to your target compiler in the "Compiler Path" field under "Host PC Root > Compiler(s) Configuration” node.
Related Question