<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Undefined Reference to global variable - Linker Error in KDS 3.0 in Kinetis Design Studio</title>
    <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445897#M4337</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I do not see any definition&amp;nbsp; of an object of named 'uartCommunication' in the sources you are sharing. So the linker is correct with its error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have this:&lt;/P&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;extern uartCommunication_parameters uartCommunication;&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt; &lt;/SPAN&gt;&lt;/H4&gt;&lt;P&gt;But this is a *declarartion*, not a *definition*.&lt;/P&gt;&lt;P&gt;You need to have something like this&lt;/P&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;uartCommunication_parameters uartCommunication; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/H4&gt;&lt;P&gt;in your application (.c file) (and of course properly initalize it).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C/C++ refresher: 'extern' for variables only declare the name, but do not define (allocate memory) for it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Aug 2015 15:56:31 GMT</pubDate>
    <dc:creator>BlackNight</dc:creator>
    <dc:date>2015-08-18T15:56:31Z</dc:date>
    <item>
      <title>Undefined Reference to global variable - Linker Error in KDS 3.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445896#M4336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;/*&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;&amp;nbsp; * UartCommunication.h&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;&amp;nbsp; */&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;typedef struct {&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;&amp;nbsp; uint16_t timeOfFlightDifference;&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;&amp;nbsp; uint16_t timeOfFlightDown;&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;&amp;nbsp; uint16_t timeOfFlightUp;&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;} uartCommunication_parameters;&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; color: #3334ca;"&gt;void uartCommunication_sendTimeOfFlightData(uartCommunication_parameters *uart);&lt;/SPAN&gt;&lt;/H4&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UartCommunication.h is then included in another source file, where the error occurs. Here is the inclusion and declaration:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;#include "UartCommunication.h"&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;extern uartCommunication_parameters uartCommunication;&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;uartCommunication_parameters *uart;&lt;/SPAN&gt;&lt;/H4&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have traced the error to this line of code, which upon commenting out removes the error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;uartCommunication_sendTimeOfFlightData(&amp;amp;uartCommunication);&lt;/SPAN&gt;&lt;/H4&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That line of code is present in the function, Scheduler_serviceInterrupt, as indicated by the error below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;'Invoking: Cross ARM C++ Linker'&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections&amp;nbsp; -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"&amp;nbsp; ./Sources/Events.o ./Sources/Scheduler.o ./Sources/SpiCommunication.o ./Sources/UartCommunication.o ./Sources/exit.o ./Sources/main.o ./Sources/myMain.o&amp;nbsp; ./Project_Settings/Startup_Code/startup.o&amp;nbsp; ./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&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;./Sources/Scheduler.o: In function `Scheduler_serviceInterrupt':&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #e23d39;"&gt;C:\Users\kschwab\workspace.kds\Ultrasonic Flow Sensor\Debug/../Sources/Scheduler.c:44: undefined reference to `uartCommunication'&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;collect2.exe: error: ld returned 1 exit status&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #e23d39;"&gt;make: *** [Ultrasonic Flow Sensor.elf] Error 1&lt;/SPAN&gt;&lt;/H4&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The name of the linker file is ProcessorExpert.ld.&lt;/P&gt;&lt;P&gt;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!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 15:37:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445896#M4336</guid>
      <dc:creator>kevynschwab</dc:creator>
      <dc:date>2015-08-18T15:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Undefined Reference to global variable - Linker Error in KDS 3.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445897#M4337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I do not see any definition&amp;nbsp; of an object of named 'uartCommunication' in the sources you are sharing. So the linker is correct with its error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have this:&lt;/P&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;extern uartCommunication_parameters uartCommunication;&lt;/SPAN&gt;&lt;/H4&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt; &lt;/SPAN&gt;&lt;/H4&gt;&lt;P&gt;But this is a *declarartion*, not a *definition*.&lt;/P&gt;&lt;P&gt;You need to have something like this&lt;/P&gt;&lt;H4&gt;&lt;SPAN style="font-family: 'courier new', courier; color: #3334ca;"&gt;uartCommunication_parameters uartCommunication; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/H4&gt;&lt;P&gt;in your application (.c file) (and of course properly initalize it).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C/C++ refresher: 'extern' for variables only declare the name, but do not define (allocate memory) for it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 15:56:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445897#M4337</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2015-08-18T15:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Undefined Reference to global variable - Linker Error in KDS 3.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445898#M4338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I apologize, I forgot to include this code, which is in UartCommunication.c:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "UartCommunication.h"&lt;/P&gt;&lt;P&gt;extern uartCommunication_parameters uartCommunication;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shouldn't that satisfy the definition?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 16:02:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445898#M4338</guid>
      <dc:creator>kevynschwab</dc:creator>
      <dc:date>2015-08-18T16:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Undefined Reference to global variable - Linker Error in KDS 3.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445899#M4339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I reread your answer and saw the C/C++ refresher, then accordingly changed the code in UartCommunication.c to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;#include "UartCommunication.h"&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;uartCommunication_parameters uartCommunication;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;By simply deleting the extern, and indeed the code does now compile. Thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 16:06:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Undefined-Reference-to-global-variable-Linker-Error-in-KDS-3-0/m-p/445899#M4339</guid>
      <dc:creator>kevynschwab</dc:creator>
      <dc:date>2015-08-18T16:06:09Z</dc:date>
    </item>
  </channel>
</rss>

