Error when referencing a model

21 次查看(过去 30 天)
SHAMBHU SAU
SHAMBHU SAU 2016-6-27
Hi,
When I am trying to run the basic model of referenced model (sldemo_mdlref_basic) I am getting below error.
>> sldemo_mdlref_basic
### Model reference SIM target (sldemo_mdlref_counter_msf.mexw64) for model sldemo_mdlref_counter is out of date because sldemo_mdlref_counter_msf.mexw64 does not exist
### Updating model reference SIM target for model: sldemo_mdlref_counter
'"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\..\..\VC\bin\vcvars64"' is not recognized as an internal or external command,
operable program or batch file.
'nmake' is not recognized as an internal or external command,
operable program or batch file.
The make command returned an error of 9009
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.
### Real-Time Workshop build procedure for model: 'sldemo_mdlref_counter' aborted due to an error.
>>
Please help me. I am using MATLAB R2010b.
Thanks
Shambhu Sau

回答(3 个)

Walter Roberson
Walter Roberson 2016-6-27
If you have not done so already, you need to install a recognized compiler. You can find the supported list at http://www.mathworks.com/support/sysreq/files/SystemRequirements-Release2010b_SupportedCompilers.pdf . It looks as if you might currently have a partial installation of VS 2010 Express; you might need to reinstall it.
Once you have installed the compiler, you need to use
mex -setup
to configure the compiler.
Once that is done, you should be able to load the model; it will need to recompile sldemo_mdlref_counter_msf for you automatically.

SHAMBHU SAU
SHAMBHU SAU 2016-6-27
Hi Roberson,
Thanks for your reply.
I downloaded VS 2010 service pack 1 from Microsoft and installed it.
Then I run mex -setup which gives the below logs.
>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Visual C++ 2010 Express in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2010 Express
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
*************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
that Microsoft Visual Studio 2010 run-time libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
*************************************************************************
Trying to update options file: C:\Users\shambhu\AppData\Roaming\MathWorks\MATLAB\R2010b\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2010b\bin\win64\mexopts\msvc100freeopts.bat
Done . . .
************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/support/solutions/en/data/1-5C27B9/?solution=1-5C27B9
Building with the -largeArrayDims option enables the new API.
************************************************************************
----------------------------------------------------------------------
Then after changing the current folder as "C:\Program Files\MATLAB\R2010b\toolbox\simulink\simdemos\simfeatures\", where the sldemo_mdlref_counter.mdl file is present, I run
>> mex sldemo_mdlref_counter.mdl
LINK : warning LNK4044: unrecognized option '/lkernel32'; ignored
LINK : fatal error LNK1104: cannot open file 'sldemo_mdlref_counter.mexw64'
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'sldemo_mdlref_counter.mexw64' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
>>
Therefore, I couldn't succeed yet to run the model.
Thanks Shambhu Sau
  1 个评论
Walter Roberson
Walter Roberson 2016-6-27
Do not mex the .mdl, just use
sldemo_mdlref_basic
and it should build the .mexw64 for you.

请先登录,再进行评论。


SHAMBHU SAU
SHAMBHU SAU 2016-6-27
Just to add with previous comment.
There is no such path or batch file as MATLAB looking for vcvars64 batch file during model reference update.
Only vcvars32.bat file is available at C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by