在我更新到最新的OSX Mavericks之后,我在Simulink中编译简单的MATLAB功能块时遇到了一些问题,如图和下面附带的代码。
function y = fcn(t)
%#codegen
%Simple MATLAB .m function to be compiled with the diagram
y = sin(t)+cos(t);
我在OSX 10.8 Mountain Lion下遇到了同样的问题,但我能够通过下载Mathworks补丁并按照this site上的说明解决问题。
使用新操作系统并升级到Xcode 5后,我按照this post中的说明更改了我的mexopts.sh
文件中的编译器和SDK信息
#PATCH: MacOSX10.8
CC='llvm-gcc-4.2'
CXX='llvm-g++-4.2'
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/'
MACOSX_DEPLOYMENT_TARGET='10.8'
ARCHS='x86_64'
到
#PATCH: MacOSX10.9
CC='llvm-gcc'
CXX='llvm-g++'
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/'
MACOSX_DEPLOYMENT_TARGET='10.9'
ARCHS='x86_64'
运行mex -setup
并重新启动MATLAB后,在尝试运行带有功能块的Simulink模型时出现以下错误(对于具有这些块的所有模型,行为相同):
Making simulation target "mextest_sfun", ...
/Applications/MATLAB.app/bin/mex -c -O -DMATLAB_MEX_FILE
-I/Applications/MATLAB.app/toolbox/stateflow/stateflow/../../../simulink/include
-I/Applications/MATLAB.app/toolbox/stateflow/stateflow/../../../extern/include
-I/Applications/MATLAB.app/stateflow/c/mex/include
-I/Applications/MATLAB.app/stateflow/c/debugger/include mextest_sfun.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
/Applications/MATLAB.app/bin/mex -c -O -DMATLAB_MEX_FILE
-I/Applications/MATLAB.app/toolbox/stateflow/stateflow/../../../simulink/include
-I/Applications/MATLAB.app/toolbox/stateflow/stateflow/../../../extern/include
-I/Applications/MATLAB.app/stateflow/c/mex/include
-I/Applications/MATLAB.app/stateflow/c/debugger/include mextest_sfun_registry.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
/Applications/MATLAB.app/bin/mex -c -O -DMATLAB_MEX_FILE
-I/Applications/MATLAB.app/toolbox/stateflow/stateflow/../../../simulink/include
-I/Applications/MATLAB.app/toolbox/stateflow/stateflow/../../../extern/include
-I/Applications/MATLAB.app/stateflow/c/mex/include
-I/Applications/MATLAB.app/stateflow/c/debugger/include c2_mextest.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
/Applications/MATLAB.app/bin/mex -silent LDFLAGS="\$LDFLAGS " -output mextest_sfun.mexmaci64 mextest_sfun.o mextest_sfun_registry.o c2_mextest.o /Applications/MATLAB.app/stateflow/c/mex/lib/maci64/sfc_mex.a /Applications/MATLAB.app/stateflow/c/debugger/lib/maci64/sfc_debug.a -L/Applications/MATLAB.app/bin/maci64 -lfixedpoint -lut -lmwmathutil -lemlrt -lmwblascompat32 -L/Applications/MATLAB.app/bin/maci64 -lippmwipt
Undefined symbols for architecture x86_64:
"sf_debug_api(int, mxArray_tag**, int, mxArray_tag const**)", referenced from:
_mexFunction in mextest_sfun_registry.o
"_callCustomFcn", referenced from:
_mdl_start_processing in sfc_mex.a(sfc_sf.o)
_mdlTerminate in sfc_mex.a(sfc_sf.o)
"_sf_machine_global_initializer", referenced from:
_mdl_start_processing in sfc_mex.a(sfc_sf.o)
"_sf_machine_global_method_dispatcher", referenced from:
_call_sf_machine_global_method_dispatcher in sfc_mex.a(sfc_sf.o)
"_sf_machine_global_terminator", referenced from:
_mdlTerminate in sfc_mex.a(sfc_sf.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
mex: link of ' "mextest_sfun.mexmaci64"' failed.
gmake: *** [mextest_sfun.mexmaci64] Error 1
我认为Undefined symbols for architecture x86_64
这是关键信息,但我真的不知道。有没有人有同样的问题,或者有人有解决方案吗?任何帮助将非常感激。谢谢!
答案 0 :(得分:1)
搜索互联网并在此论坛上等待答案后没有结果,我的问题的解决方案最终升级到MATLAB 2013a。
此外,还需要对mexopts.sh
文件进行一些修改。只需将10.7
的所有实例替换为10.8
或10.9
。这两个都适合我,但我最终用10.9
替换它,因为我正在运行小牛队。
可以在this site找到“官方”解决方案。