Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Function in included header file won't work(The project fails to build due to "undefined references" to functions in a header file that is included)
Function in included header file won't work [message #1785498] Sun, 15 April 2018 18:45 Go to next message
Sam Meredith is currently offline Sam MeredithFriend
Messages: 1
Registered: April 2018
Junior Member
I'm new to Eclipse so I apologise if this is a daft question.

So I'm using Eclipse-based System Workbench for STM32. I'm trying to use several mathematical functions from a header file (arm_math.h, from a folder of multiple files called CMSIS) in multiple SRC .c files. When I right click and "open declaration" on these functions it takes me straight to their declaration in arm_math.h, but it gives error messages (in the console and red underlined in the coding section) saying that it is an "undefined reference to (function)." The functions themselves are definitely being used properly and I've definitely included the right header file, and I've also fiddled around with the compiler and linker but I can't figure out what's wrong with it.

The console reads:

19:25:01 **** Incremental Build of configuration Debug for project Sem1CompProg ****
make -j4 all
Building target: Sem1CompProg.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -
L"C:\Users\Sam\workspace\Sem1CompProg\CMSIS" -
-Wl, -Wl,--gc-sections -o "Sem1CompProg.elf" @"objects.list" -lm

src/FFT.o:(.data+0x0): undefined reference to `arm_cfft_sR_f32_len32'
src/FFT.o:(.data+0x4): undefined reference to `arm_cfft_sR_f32_len64'
src/FFT.o:(.data+0x8): undefined reference to `arm_cfft_sR_f32_len128'
src/FFT.o:(.data+0xc): undefined reference to `arm_cfft_sR_f32_len256'
src/FFT.o:(.data+0x10): undefined reference to `arm_cfft_sR_f32_len512'
src/FFT.o:(.data+0x14): undefined reference to `arm_cfft_sR_f32_len1024'
src/FFT.o: In function `FFT':
C:\Users\Sam\workspace\Sem1CompProg\Debug/../src/FFT.c:51: undefined reference to `arm_cfft_f32'
C:\Users\Sam\workspace\Sem1CompProg\Debug/../src/FFT.c:55: undefined reference to `arm_cmplx_mag_f32'
C:\Users\Sam\workspace\Sem1CompProg\Debug/../src/FFT.c:69: undefined reference to `arm_max_f32'
C:\Users\Sam\workspace\Sem1CompProg\Debug/../src/FFT.c:77: undefined reference to `arm_mean_f32'
src/main.o: In function `main':
C:\Users\Sam\workspace\Sem1CompProg\Debug/../src/main.c:147: undefined reference to `arm_max_f32'
collect2.exe: error: ld returned 1 exit status
makefile:59: recipe for target 'Sem1CompProg.elf' failed
make: *** [Sem1CompProg.elf] Error 1

19:25:02 Build Finished (took 1s.228ms)

Again, apologies if this is a daft question.
Re: Function in included header file won't work [message #1785573 is a reply to message #1785498] Tue, 17 April 2018 03:21 Go to previous message
David VavraFriend
Messages: 772
Registered: October 2012
Senior Member
"Undefined reference" is a ink error.

The library (or object file) contaiming the function
wasn't given to the linker or wasn't used properly.

You'll need to find out where the function is defined
and give the library or object file to the linker in the proper order.

UPDATE: This might help

For instance, arm_cfft_sR_f32_len32 is in arm_const_structs.c
It's actually a global variable of type arm_cfft_instance_f32
So you'll have to link arm_const_structs.o or a library containing it.

Use the html link to find the rest.

[Updated on: Tue, 17 April 2018 14:54]

Report message to a moderator

Previous Topic:linking to shared libraries (-o) in Eclipse Oxygen C/C++ IDE
Next Topic:Flash download related issues when using GDB SEGGER J-Link Debugging plugin + Cortex-M0 device
Goto Forum:

Current Time: Thu Sep 20 03:32:24 GMT 2018

Powered by FUDForum. Page generated in 0.01489 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top