STM32F4xx Linker Error when using Static Library: is incompatible with i386:x86-64 output

8 views (last 30 days)
My Project for Embedded Coder Support Package for STMicroelectronics STM32 Processors does not compile in External Mode with my STM32 Nucleo F413ZH Board.
I'm trying to use an .a-Library precompiled for my STM32F413 (included via Custom Code -> Libraries). But when clicking Monitor&Tune it gives me this error:
Errors encountered while building custom code simulation target for model 'stm32_external_mode'. Fix the errors in your custom code or disable 'Import custom code' if your custom code has incompatibilities.
Caused by:
C:/ProgramData/MATLAB/SupportPackages/R2023a/3P.instrset/mingw_w64.instrset/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: unknown architecture of input file `c:\users\test\documents\coding\simulink_programme\simulinkprojekt\libtest.a(test.o)' is incompatible with i386:x86-64 output
c:\users\test\documents\coding\simulink_programme\simulinkprojekt\libtest.a(test.o): could not read symbols: Invalid operation
collect2.exe: error: ld returned 1 exit status
This tells me that Simulink tried to compile the Code with Mingw i guess?, but i need it to get compiled with the ARM GNU GCC Compiler.
I set the correct Toolchain under Code Generation (just left everything as it was from the STM32 Examples for Embedded Coder)
Has someone an idea what i can do that my code will compile?
Thank you.

Answers (1)

Infinite_king
Infinite_king on 8 Jan 2024
Edited: Infinite_king on 8 Jan 2024
Hi Tim Scheuermann,
I understand that you are facing compilation errors in Simulink's External Mode with your STM32 Nucleo F413ZH Board, specifically related to using a precompiled library (.a file) for your STM32F413.
The possible reason for this error is that Simulink is attempting to compile the code using the MinGW toolchain, which is incompatible with the ARM architecture of your STM32F413. This mismatch in architectures results in a linker error during compilation.
To resolve this issue, follow the below steps,
  • Double-check and ensure that the ARM toolchain is correctly set for code generation in Simulink.
  • Refer this MATLAB documentation to setup the toolchain, https://www.mathworks.com/help/ecoder/stmicroelectronicsstm32f4discovery/ug/setup-armclang-compiler.html
  • Verify the Custom Code settings to ensure that the library (your_lib.a) is specified correctly and compiled for the ARM architecture.
  • If you have access to the source code of the library, consider recompiling it with the same ARM compiler to ensure compatibility.
  • Clean your Simulink project to remove any previously compiled items.
  • Check and update the paths to the ARM compiler in your MATLAB environment.
  • Ensure that your MATLAB release is compatible with the version of the Embedded Coder Support Package for STMicroelectronics STM32 Processors that you have installed.
For more information, refer the following resources,
Hope this is helpful.

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!