Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world.
And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download two short videos (registration required) highlighting:

System Workbench for STM32


Problem with "undefined reference to" [SOLVED]

Hello,

I know that this question has been posted many times, but none of the proposed solutions have worked.

The problem I have should be easy to fix, bu I cannot find the way to do it. I have tried many ways to do the same thing, but all of them lead to the same problem, which is:

I:/Ac6/SystemWorkbench/workspace/nz32-sc151-fir_example/Src/main.cpp:174: undefined reference to `arm_snr_f32(float*, float*, unsigned long)’
collect2.exe: error: ld returned 1 exit status

The function arm_snr_f32 is defined in math_helper.h and implemented in math_helper.c. Files can be found on: https://github.com/ARM-software/CMSIS_5/tree/develop/CMSIS/DSP/Examples/ARM/arm_fir_exampleQuestion

The files are in a folder called Inc in my project’s workspace. Then, in the project explorer, I linked this folder and its files. I have also added the folder in Project properties > C/C++ General > Path and Symbols: “${WorkspaceDirPath}/.../Inc”

When I build the project, I see in the Debug folder that the object file math_helper.o is being created. However, my main.cpp program complains again and again.

Other things I have tried are e.g., creating a header file with the definition of some function and another source file with the implementation, both in the same src folder where my main.cpp is located. It can find the header, but when it comes to building the project successfully, reference error.

I would very much appreciate any help here.

Many thanks

David

France

Hi David,

The problem here is that the math_helper.c file is a C program and your main.cpp is obviously a C++ program. You must slightly modify the math_helper.h file so that it declares its functions correctly to be called from C++: You should add, just after line 47 in math_helper.h:
#ifdef __cplusplus
extern "C" {
#endif
and just before the final #endif
#ifdef __cplusplus
}
#endif

so that your functions are properly declared as C functions when math_helper.h is included in main.cpp.

Hope this helps,

Bernard (Ac6)

Hello Bernard,

I just added the lines of code you indicated and all works fine now. Many thanks.

Though I have a lot of experience on embedded programming (only C), it is now when I am transitioning to C and C++ projects, and this is something I didn’t know of. It is always good to learn something new.

Thanks again,

Best
David