问题描述
我通过Matlab coder将MATLAB写入函数转换为C.当我得到转换的文件,转换的函数总是有第一个输入参数 const emlrtStack * sp
。现在,当我试图在VC ++ 2013上测试它时,IntelliSense会提到上述错误。
I am converting a MATLAB written function into C by "Matlab coder". After I get the converted files , the converted function always have first input argument as const emlrtStack *sp
. Now when I am trying to test it on VC++ 2013, IntelliSense is giving mentioned above error.
我手动尝试在 emlrt中找到此标识符。 h
文件,但没有这样的东西存在。我试图转换一个简单的乘法函数与两个输入参数[像, c = mul(a,b) ],但仍然转换的函数有这个额外的参数除了 和 b 。
(这意味着这个参数不是函数特定的)。
I manually tried to locate this identifier in emlrt.h
file but no such thing is present there. I tried to convert a simple multiply function with two input arguments[like, c=mul(a,b)] but still the converted function has this extra argument inside the function in addition to a and b.(which means this argument is not function specific).
如果有人有解决方案,或遇到这样的问题,请分享或帮助。
If someone has a solution to this or have experienced a problem like this, please share or help.
此外,如果有人知道如何简单地测试这些转换的函数,那将是非常感谢的额外帮助。
Moreover If someone know how to simply test these converted functions, it would be a much appreciated additional help .
推荐答案
这可能是为功能,而不是独立的目标。 MEX函数是C,C ++或Fortran的二进制文件,可以像普通的MATLAB函数一样调用。生成代码以产生MEX函数允许两个事情。首先,您可以在MATLAB中测试您生成的代码,因为您可以像任何其他函数一样从MATLAB调用MEX函数。在你做代码生成并尝试调用它之后,查找名为 mul_mex.mex *
的文件: mul_mex(1,2)
。生成MEX函数的另一个用途是它通常比生成MEX函数的MATLAB代码更快。
It is likely that the code that was generated for a MEX function rather than a standalone target. MEX functions are binaries written C, C++ or Fortran that can be called like a normal MATLAB function. Generating code to produce a MEX function allows two things. First, you can test your generated code in MATLAB because you can call the MEX function from MATLAB like any other function. Look for a file named mul_mex.mex*
after you do code generation and try to call it: mul_mex(1,2)
. The other use for generating a MEX function is that it can often be faster than the MATLAB code from which it was generated. MEX functions are only used in the context of MATLAB.
您看到的参数 emlrtStack *
出现在MEX生成的帮助运行时错误报告的代码。
The parameter emlrtStack*
that you saw appears in MEX generated code to aid in runtime error reporting. It is not present in standalone code that is designed to be run outside of MATLAB.
如果你想在Visual Studio中使用生成的代码,或者在MATLAB之外,你应该选择一个独立的目标,LIB,DLL或EXE。 显示如何更改输出类型。总而言之,如果使用命令行,您可以说:
If you want to use the generated code in Visual Studio, or outside of MATLAB you should choose one of the standalone targets, LIB, DLL, or EXE. This page shows how to change the output type. To summarize, if using the command line you could say:
cfg = coder.config('lib'); %or 'dll' or 'exe'
codegen mul -config cfg -args {1,2}
$ b b
如果使用项目界面,请单击 Build
选项卡,然后在输出类型下拉菜单中选择静态库或共享库。
If using the project interface, you click on the Build
tab and choose static library or shared library in the "Output type" dropdown menu.
我建议阅读演示如何在Visual Studio中使用生成的DLL。
I would recommend reading this example that demonstrates how to use a generated DLL in Visual Studio.
这篇关于智能感知错误标识符“emlrtStack”未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!