AnsweredAssumed Answered

Undefined Reference to global variable - Linker Error in KDS 3.0

Question asked by Kevyn Schwab on Aug 18, 2015
Latest reply on Aug 18, 2015 by Kevyn Schwab

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

  */

typedef struct {

  uint16_t timeOfFlightDifference;

  uint16_t timeOfFlightDown;

  uint16_t timeOfFlightUp;

} uartCommunication_parameters;

void uartCommunication_sendTimeOfFlightData(uartCommunication_parameters *uart);

 

UartCommunication.h is then included in another source file, where the error occurs. Here is the inclusion and declaration:

 

#include "UartCommunication.h"

extern uartCommunication_parameters uartCommunication;

uartCommunication_parameters *uart;

 

I have traced the error to this line of code, which upon commenting out removes the error:

 

uartCommunication_sendTimeOfFlightData(&uartCommunication);

 

That line of code is present in the function, Scheduler_serviceInterrupt, as indicated by the error below:

 

'Invoking: Cross ARM C++ Linker'

arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections  -g3 -T "C:/Users/kschwab/workspace.kds/Ultrasonic Flow Sensor/Project_Settings/Linker_Files/ProcessorExpert.ld" -Xlinker --gc-sections -L"C:/Users/kschwab/workspace.kds/Ultrasonic Flow Sensor/Project_Settings/Linker_Files" -Wl,-Map,"Ultrasonic Flow Sensor.map" -specs=nano.specs -specs=nosys.specs -o "Ultrasonic Flow Sensor.elf"  ./Sources/Events.o ./Sources/Scheduler.o ./Sources/SpiCommunication.o ./Sources/UartCommunication.o ./Sources/exit.o ./Sources/main.o ./Sources/myMain.o  ./Project_Settings/Startup_Code/startup.o  ./Generated_Code/AS1.o ./Generated_Code/ASerialLdd1.o ./Generated_Code/BitIoLdd1.o ./Generated_Code/BitIoLdd2.o ./Generated_Code/BitIoLdd3.o ./Generated_Code/BitIoLdd4.o ./Generated_Code/BitIoLdd5.o ./Generated_Code/BluLedDout.o ./Generated_Code/Cpu.o ./Generated_Code/GrnLedDout.o ./Generated_Code/Maxim_pullUpResistor.o ./Generated_Code/PE_LDD.o ./Generated_Code/RedLedDout.o ./Generated_Code/RtiTimer.o ./Generated_Code/SInt.o ./Generated_Code/SMasterLdd1.o ./Generated_Code/SlaveSelect.o ./Generated_Code/TU1.o ./Generated_Code/TimerIntLdd1.o ./Generated_Code/UltrasonicFlowSPI.o ./Generated_Code/Vectors.o ./Generated_Code/WAIT1.o  

./Sources/Scheduler.o: In function `Scheduler_serviceInterrupt':

C:\Users\kschwab\workspace.kds\Ultrasonic Flow Sensor\Debug/../Sources/Scheduler.c:44: undefined reference to `uartCommunication'

collect2.exe: error: ld returned 1 exit status

make: *** [Ultrasonic Flow Sensor.elf] Error 1

 

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!

Outcomes