运行Simulink模型,生成用于编译的C / C ++代码

时间:2014-04-04 21:46:41

标签: c++ matlab simulink mex

当我尝试运行simulink模型时,遇到与C / C ++代码的编译和链接相关的以下错误

C:\Comms\slprj\_sfprj\quantizer_sim\_self\sfun\src>call "mexopts.bat"  

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 
Copyright (C) Microsoft Corporation.  All rights reserved. 

### Compiling "quantizer_sim_sfun.c" 
    cl.exe /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD   /I "C:\Program Files\MATLAB\R2012b\extern\include" /I "C:\Program Files\MATLAB\R2012b\simulink\include" /I "C:\Program Files\MATLAB\R2012b\stateflow\c\mex\include" /I "C:\Program Files\MATLAB\R2012b\stateflow\c\debugger\include"  "quantizer_sim_sfun.c" 
quantizer_sim_sfun.c 
### Compiling "quantizer_sim_sfun_registry.c" 
    cl.exe /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD   /I "C:\Program Files\MATLAB\R2012b\extern\include" /I "C:\Program Files\MATLAB\R2012b\simulink\include" /I "C:\Program Files\MATLAB\R2012b\stateflow\c\mex\include" /I "C:\Program Files\MATLAB\R2012b\stateflow\c\debugger\include"  "quantizer_sim_sfun_registry.c" 
quantizer_sim_sfun_registry.c 
### Compiling "c1_quantizer_sim.c" 
    cl.exe /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD   /I "C:\Program Files\MATLAB\R2012b\extern\include" /I "C:\Program Files\MATLAB\R2012b\simulink\include" /I "C:\Program Files\MATLAB\R2012b\stateflow\c\mex\include" /I "C:\Program Files\MATLAB\R2012b\stateflow\c\debugger\include"  "c1_quantizer_sim.c" 
c1_quantizer_sim.c 
### Compiling "c2_quantizer_sim.c" 
    cl.exe /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD   /I "C:\Program Files\MATLAB\R2012b\extern\include" /I "C:\Program Files\MATLAB\R2012b\simulink\include" /I "C:\Program Files\MATLAB\R2012b\stateflow\c\mex\include" /I "C:\Program Files\MATLAB\R2012b\stateflow\c\debugger\include"  "c2_quantizer_sim.c" 
c2_quantizer_sim.c 
### Linking ... 
    link.exe /nologo /dll /OPT:NOREF /export:mexFunction  /OUT:quantizer_sim_sfun.mexw64 /map:"quantizer_sim_sfun.map"  "C:\Program Files\MATLAB\R2012b\stateflow\c\mex\lib\win64\sfc_mex.lib" "C:\Program Files\MATLAB\R2012b\stateflow\c\debugger\lib\win64\sfc_debug.lib"  "C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft\libmx.lib" "C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft\libmex.lib" "C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft\libmat.lib" "C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft\libfixedpoint.lib" "C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft\libut.lib" "C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft\libmwmathutil.lib" "C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft\libemlrt.lib" "C:\Program Files\MATLAB\R2012b\lib\win64\libippmwipt.lib"   "C:\Program Files\MATLAB\R2012b\extern\lib\win64\microsoft\libmwblascompat32.lib" @quantizer_sim_sfun.mol 
LINK : fatal error LNK1104: cannot open file 'MSVCRT.lib' 
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe"' : return code '0x450' 
Stop. 



Error using quantizer_script (line 24)
Error using targetman>throw_make_error (line 588)
(SLSF Diagnostic)

目前,Matlab配置了Visual Studio 2010编译器。另外,我检查了从Matlab正确设置了LIBPATH。我也在运行Matlab和管理员的权限。

如何解决LINKNMAKE错误?

1 个答案:

答案 0 :(得分:2)

Visual Studio Express版本为no longer supported

当您运行mex -setup时,请选择SDK 7.1(download here,在安装过程中选择x64编译器。)

另外请务必安装.NET Framework 4.0 runtime

大但是:使用SDK,a bug会删除编译器(details from MS)!看看here too。该补丁位于Microsoft's website

有关如何下载和配置适用于MATLAB的SDK的提示,请参阅this support article。也许确认在安装中选择了编译器。