Getting LCCMAKE error code 12 when compiling TestHarness with imported C code

11 views (last 30 days)
Hello,
this is my first request for support in this community; so please let me know when you need more information to support me.
Currently, I'm trying to use Simulink Test for building a Test Harness to test C-code. I have imported C-code into a model with a C-caller function. While doing this, the compiler checked the code and was ok with the content.
After that I created a TestHarness with TestSequences as configuration. Then I compiled the TestHarness and I encounter a compile error "LCCMAKE.exe: Error Code 12". Unfortenately, without any explanation with it.
I can't find any explanation regarding this Error Code 12; so that makes it very hard to understand where the problem is.
Does anyone know what the meaning of this Error Code 12 is?
BTW, regarding the code, I believe the code is correct, because we also use it with another compiler GHS (for the embedded application) and there we encounter no errors.
Many thanks for the support!
################ UPDATE ########################
I found the following in the compile results (maybe that helps):
extdev.obj .text: undefined reference to 'Spi_WriteIB'
extdev.obj .text: undefined reference to 'Spi_AsyncTransmit'
extdev.obj .text: undefined reference to 'Spi_GetSequenceResult'
extdev.obj .text: undefined reference to 'Spi_ReadIB'
extdev.obj .text: undefined reference to 'Gpt_GetTimeElapsed'
extdev.obj .text: undefined reference to 'StateMach_stSysMode'
extdev.obj .text: undefined reference to 'Spi_SetAsyncMode'
Not sure what the undefined reference means..
###############################################
BR,
Frank

Answers (1)

Sanchari
Sanchari on 8 Feb 2024
Hello Frank,
The error code "LCCMAKE.exe: Error Code 12" is a generic error message from the LCC compiler (default C compiler of MATLAB for Windows). The "undefined reference" errors indicate that the linker is unable to find the implementations of the functions that are being called from “extdev.obj”. This typically means that the corresponding object files or libraries that contain the definitions of these functions are not being linked into the final executable.
Here are some steps to resolve the errors:
  1. Check Include Paths: Ensure that all the header files declaring these functions are included in the project and that the ‘include paths’ are correctly set in the Simulink model configuration parameters.
  2. Verify Library Paths: If these functions are part of external libraries, make sure that the paths to these libraries are correctly specified in the Simulink model configuration parameters. This will typically be under the "Custom Code" section where you can specify additional include directories, source files, and libraries.
  3. Add Source Files: If these function definitions are in other source files, you need to add them to the Simulink project so that they are compiled and linked together with the rest of the code.
  4. Check for Conditional Compilation: Ensure that there are no conditional compilation directives (like #ifdef, #ifndef, #endif) that might be excluding the implementation of these functions from the compilation.
  5. Correct Compiler Configuration: Since you mentioned that the code compiles fine with the GHS compiler, there might be compiler-specific configurations or pragmas that are not compatible with the LCC compiler. Check for any such configurations and adjust them for compatibility with LCC.
  6. Link Order: Sometimes the order in which libraries and object files are linked can cause "undefined reference" errors. Ensure that the objects and libraries are linked in the correct order.
  7. External Dependencies: If the functions are part of external hardware libraries or SDKs, you may need to provide stubs or mock implementations for testing purposes or ensure that the actual libraries are linked.
  8. Use a Different Compiler: If LCC is not suitable for your codebase, consider switching to a different compiler that is more compatible with your code. You can change the compiler used by MATLAB/Simulink by running mex-setup c in the MATLAB Command Window and selecting an appropriate compiler.
To further troubleshoot, you can try compiling the C code outside of Simulink using the same LCC compiler to see if you get a more detailed error message. This might help isolate the issue to either the code or the way it's being integrated into Simulink.
The following links may be useful as well:
  1. Invalid MEX-file error (MathWorks Documentation): https://www.mathworks.com/help/comm/rtlsdrradio/ug/common-problems-and-fixes.html#mw_11a478c1-2687-4486-9d67-b86cb589012c
  2. Template Makefiles and Make options (MathWorks Documentation): https://www.mathworks.com/help/rtw/ug/template-makefiles-and-make-options.html?searchHighlight=LCC%20Make&s_tid=srchtitle_support_results_1_LCC%20Make
  3. Make error in Simulink- Division by 0 (ML Answer): https://www.mathworks.com/support/search.html/answers/22096-make-error-in-simulink-division-by-zero.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:simulink/simulink-environment-customization&page=1
Hope this helps!

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!