Hello Everyone,
I have an error message that seems easy to fix, but I have used all of my brain cells trying to figure this out after a couple of days.
I have the Keil IDE with the ARM® Compiler toolchain Version 5.02
The processor is a stm32f303
This is my error message.
UART STM32F3.axf: Error: L6218E: Undefined symbol ucInputBuffer (referred from routine.o).
The "ucInputBuffer" is my own variable.
I have the #include "routine.h" where the "ucInputBuffer" is declared.
Inside the "routine.h" file I declare the variable like shown below.
extern volatile unsigned char ucInputBuffer;
This is my compiler control string.
-c --cpu Cortex-M4.fp -g -O0 --apcs=interwork -I..\STM32F3 -I C:\Keil\ARM\RV31\INC -I C:\Keil\ARM\CMSIS\Include -I C:\Keil\ARM\Inc\ST\STM32F30x -o "*.o" --omf_browse "*.crf" --depend "*.d"
This is the linker control string.
--cpu Cortex-M4.fp *.o --strict --scatter "UART STM32F3.sct" --summary_stderr --info summarysizes --map --xref --callgraph --symbols --info sizes --info totals --info unused --info veneers --list ".\UART STM32F3.map" -o "UART STM32F3.axf"
Any ideas anyone???
Thankyou
'extern' tells the compiler that there is a variable declared somewhere else that is of that type, but it doesn't actually reserve the memory.
This allows code to reference variables not declared in its local scope.
When the linker goes to stitch everything together and resolve the references, it's looking for the actual variable which must be declared (once and only once).
You're missing the line in a C file where you declare your variable:
volatile unsigned char ucInputBuffer;
(Note the lack of 'extern'.)
Thank-you for that explanation. It was well done and helped me to understand the difference between declaring and definition.
View all questions in Keil forum