I am having issues building out my project. The console gives the error: "undefined reference to 'uartCommunication'", where uartCommunication is an external global structure. Here is the code that instantiates the structure:
UartCommunication.h is then included in another source file, where the error occurs. Here is the inclusion and declaration:
I have traced the error to this line of code, which upon commenting out removes the error:
That line of code is present in the function, Scheduler_serviceInterrupt, as indicated by the error below:
The name of the linker file is ProcessorExpert.ld.
I have no knowledge of how to even approach reading a linker file, much less tinker with it to fix this issue. Any help or direction would be much appreciated!
Solved! Go to Solution.
Hello,
I do not see any definition of an object of named 'uartCommunication' in the sources you are sharing. So the linker is correct with its error message.
You have this:
But this is a *declarartion*, not a *definition*.
You need to have something like this
in your application (.c file) (and of course properly initalize it).
C/C++ refresher: 'extern' for variables only declare the name, but do not define (allocate memory) for it.
I hope this helps,
Erich
Hello,
I do not see any definition of an object of named 'uartCommunication' in the sources you are sharing. So the linker is correct with its error message.
You have this:
But this is a *declarartion*, not a *definition*.
You need to have something like this
in your application (.c file) (and of course properly initalize it).
C/C++ refresher: 'extern' for variables only declare the name, but do not define (allocate memory) for it.
I hope this helps,
Erich
I reread your answer and saw the C/C++ refresher, then accordingly changed the code in UartCommunication.c to:
#include "UartCommunication.h"
uartCommunication_parameters uartCommunication;
By simply deleting the extern, and indeed the code does now compile. Thank you for your help!
I apologize, I forgot to include this code, which is in UartCommunication.c:
#include "UartCommunication.h"
extern uartCommunication_parameters uartCommunication;
Shouldn't that satisfy the definition?