How to fix "undefined reference" error?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to fix "undefined reference" error?

Jump to solution
80 Views
Contributor I

Hello

I'm developing code for evkmimxrt1060 using the mcuxpressoide IDE.
I added unity (https://github.com/ ThrowTheSwitch/Unity) testcode in iled_blinky example.
When I build the attachment, I get this error ↓

01:46:47 **** Build of configuration Debug for project evkmimxrt1060_iled_blinky ****
make -r -j8 all
Building target: evkmimxrt1060_iled_blinky.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -Xlinker -Map="evkmimxrt1060_iled_blinky.map" -Xlinker --gc-sections -Xlinker -print-memory-usage -Xlinker --sort-section=alignment -Xlinker --cref -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -T evkmimxrt1060_iled_blinky_Debug.ld -o "evkmimxrt1060_iled_blinky.axf" ./xip/evkmimxrt1060_flexspi_nor_config.o ./xip/evkmimxrt1060_sdram_ini_dcd.o ./xip/fsl_flexspi_nor_boot.o ./utilities/fsl_assert.o ./utilities/fsl_debug_console.o ./utilities/fsl_str.o ./unity/unity.o ./unity/unity_fixture.o ./startup/startup_mimxrt1062.o ./source/led_blinky.o ./source/semihost_hardfault.o ./drivers/fsl_clock.o ./drivers/fsl_common.o ./drivers/fsl_gpio.o ./drivers/fsl_lpuart.o ./device/system_MIMXRT1062.o ./component/uart/lpuart_adapter.o ./component/serial_manager/serial_manager.o ./component/serial_manager/serial_port_uart.o ./component/lists/generic_list.o ./board/board.o ./board/clock_config.o ./board/pin_mux.o
Memory region Used Size Region Size %age Used
BOARD_FLASH: 25332 B 8 MB 0.30%
/usr/local/mcuxpressoide-11.1.1_3241/ide/plugins/com.nxp.mcuxpresso.tools.linux_11.1.0.202001081728/tools/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: ./source/led_blinky.o: in function `main':
SRAM_DTC: 8624 B 128 KB 6.58%
SRAM_ITC: 0 GB 128 KB 0.00%
SRAM_OC: 0 GB 768 KB 0.00%
BOARD_SDRAM: 0 GB 30 MB 0.00%
NCACHE_REGION: 0 GB 2 MB 0.00%
/home/(user name)/Documents/MCUXpresso_11.1.1_3241/workspace/evkmimxrt1060_iled_blinky/Debug/../source/led_blinky.c:81: undefined reference to `RunAllTests'
makefile:40: recipe for target 'evkmimxrt1060_iled_blinky.axf' failed
collect2: error: ld returned 1 exit status
make: *** [evkmimxrt1060_iled_blinky.axf] Error 1
"make -r -j8 all" terminated with exit code 2. Build might be incomplete.

01:46:48 Build Failed. 4 errors, 0 warnings. (took 787ms)

If you have any hints that might help resolve this error, please let me know.

Thank you,
mari

1 Solution
26 Views
Senior Contributor II

Your problem is that the linker does not find RunAllTests:

/home/(user name)/Documents/MCUXpresso_11.1.1_3241/workspace/evkmimxrt1060_iled_blinky/Debug/../source/led_blinky.c:81: undefined reference to `RunAllTests'

And the root cause is that your folders are not included in the build. The need to have this small blue 'C' on it:

pastedImage_1.png

By default, if you add folders in the latest versions of Eclipse they are not automatically added to the build: you need to uncheck that 'exclude from build' setting, see Exclude Source Files from Build in Eclipse | MCU on Eclipse 

I hope this helps,

Erich

View solution in original post

2 Replies
27 Views
Senior Contributor II

Your problem is that the linker does not find RunAllTests:

/home/(user name)/Documents/MCUXpresso_11.1.1_3241/workspace/evkmimxrt1060_iled_blinky/Debug/../source/led_blinky.c:81: undefined reference to `RunAllTests'

And the root cause is that your folders are not included in the build. The need to have this small blue 'C' on it:

pastedImage_1.png

By default, if you add folders in the latest versions of Eclipse they are not automatically added to the build: you need to uncheck that 'exclude from build' setting, see Exclude Source Files from Build in Eclipse | MCU on Eclipse 

I hope this helps,

Erich

View solution in original post

26 Views
Contributor I

Thank you, the problem has been successfully resolved.
I can start learning this board! :smileyhappy:!!

0 Kudos