- MATLAB Coder or the “codegen” command generates a batch file (.bat on Windows or a shell script on Linux/Mac) that contains the necessary commands and flags to compile the C files into binaries. This batch file is tailored to your specific project and includes paths to the required MATLAB runtime libraries.
- Locate this batch file in your code generation output directory and execute it to compile your project. This should resolve the undefined reference errors by ensuring all necessary libraries are linked.
Getting compilation error with generated c code with Emlrt functions
15 次查看(过去 30 天)
显示 更早的评论
I used the matlab code generator and generated the c code from my project.
The generated code i was compiling using gcc compiler and everything was find but al tast i am getting the undefined reference error for following function which is looks like dfetching the matlab library which i not have.
The functions in which i am getting error declarations i found in emlrt.h file but definitions i am not able to get.
The Errors are below
53: undefined reference to `emlrtAlias'
54: undefined reference to `emlrtDestroyArray'
allIn':
69: undefined reference to `emlrtCheckBuiltInR2012b'
72: undefined reference to `emlrtImportArrayR2015b'
73: undefined reference to `emlrtDestroyArray'
lIn':
90: undefined reference to `emlrtAlias'
91: undefined reference to `emlrtDestroyArray'
lOut':
106: undefined reference to `emlrtCreateNumericArray'
107: undefined reference to `emlrtMxGetData'
111: undefined reference to `emlrtAssign'
131: undefined reference to `emlrtAliasP'
151: undefined reference to `emlrtEnterRtStackR2012b'
152: undefined reference to `emlrtLeaveRtStackR2012b'
The above snaps is a part of errors.
Please provide me the solution for that errors.
0 个评论
回答(1 个)
Samay Sagar
2024-8-21,8:31
Hi Manish,
I understand that you are encountering errors while trying to compile C code generated from MATLAB.
The error logs suggest that the generated C code is trying to link against MATLAB's runtime libraries, but these libraries are not available in your current setup.
This typically happens when the necessary MATLAB runtime libraries are not included in your compilation process.
Here is how you can address this issue
1. Use the Generated Batch File:
2. Configurations for Executable Generation: When using “codegen” to generate C code, you can configure the project to create a standalone executable. This involves setting the appropriate build configurations. You can refer the following documentation to generate executable for your MATLAB code:
For more information about Code Generation, you can refer the following documentation: https://www.mathworks.com/help/overview/code-generation.html
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Generating Code 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!