<?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: Linker error in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564131#M17422</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave Such on Tue Jan 20 14:31:43 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;New to forums too.&amp;nbsp; Not sure if this is proper way to "post your project" or not but it is attached to this reply as a zip file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:41:02 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T23:41:02Z</dc:date>
    <item>
      <title>Linker error</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564129#M17420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave Such on Tue Jan 20 14:16:25 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Very new to XPresso workbench.&amp;nbsp; Have been using IAR for several years with LPC2292/2294.&amp;nbsp; I have several projects that are successfully built using IAR.&amp;nbsp; As a way of introducing myself to Xpresso, I decide to take one of my smaller ones and see what it takes to port over to this compiler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After about a week of porting about 20 source files, I can now compile all of them without errors or warnings.&amp;nbsp; However, when it goes to link it, I am getting several errors from main.o about -- undefined reference to --.&amp;nbsp; These are referring to variables / functions that are defined in other header files, used in main.c.&amp;nbsp; I have searched through this forum as well as the FAQ and have not found anything to help me.&amp;nbsp; After trying several things and going through the options, I am at a loss.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I decided to simplify this.&amp;nbsp; I created a new project using the wizard.&amp;nbsp; I added one c file with its h file.&amp;nbsp; Added one function in it, defined it in the h file along with a variable.&amp;nbsp; I then called this function from main() along with incrementing the variable.&amp;nbsp; Same results.&amp;nbsp; Both files compile but I get the linker error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help/suggestions would be appreciated.&amp;nbsp; Here is a sample from the console&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;15:57:09 **** Incremental Build of configuration Debug for project Test ****&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;make all &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Building file: ../src/hello.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invoking: MCU C Compiler&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arm-none-eabi-gcc -D__REDLIB__ -DDEBUG -D__CODE_RED -I"C:\Documents and Settings\Dave\My Documents\LPCXpresso_7.3.0_186\workspace\DPA4plus\src" -O0 -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=arm7tdmi -D__REDLIB__ -specs=redlib.specs -MMD -MP -MF"src/hello.d" -MT"src/hello.o" -MT"src/hello.d" -o "src/hello.o" "../src/hello.c"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Finished building: ../src/hello.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Building file: ../src/main.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invoking: MCU C Compiler&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arm-none-eabi-gcc -D__REDLIB__ -DDEBUG -D__CODE_RED -I"C:\Documents and Settings\Dave\My Documents\LPCXpresso_7.3.0_186\workspace\DPA4plus\src" -O0 -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=arm7tdmi -D__REDLIB__ -specs=redlib.specs -MMD -MP -MF"src/main.d" -MT"src/main.o" -MT"src/main.d" -o "src/main.o" "../src/main.c"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Finished building: ../src/main.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Building target: Test.axf&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Invoking: MCU Linker&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arm-none-eabi-gcc -nostdlib -Xlinker -Map="Test.map" -Xlinker --gc-sections -mcpu=arm7tdmi -T "Test_Debug.ld" -o "Test.axf"&amp;nbsp; ./src/cr_startup_lpc22.o ./src/crp.o ./src/hello.o ./src/main.o&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;./src/main.o: In function `main':&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Dave2\60xxwork\Test\Debug/../src/main.c:36: undefined reference to `ulDebug1'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;collect2.exe: error: ld returned 1 exit status&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;make: *** [Test.axf] Error 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;15:57:10 Build Finished (took 1s.547ms)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ulDebug is the variable defined in hello.h&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:41:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564129#M17420</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564130#M17421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Tue Jan 20 14:25:37 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Please post your project,so we can debug what you are doing wrong.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:41:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564130#M17421</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564131#M17422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave Such on Tue Jan 20 14:31:43 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;New to forums too.&amp;nbsp; Not sure if this is proper way to "post your project" or not but it is attached to this reply as a zip file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:41:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564131#M17422</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564132#M17423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Tue Jan 20 14:33:44 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;If I remember my "C", the hello.h should be &lt;/SPAN&gt;&lt;I&gt;declaring&lt;/I&gt;&lt;SPAN&gt; not &lt;/SPAN&gt;&lt;I&gt;defining&lt;/I&gt;&lt;SPAN&gt; variables and/or function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I.e Hello.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
...
int aVariable = 42; // if it should be initialised [UK spelling!]
...
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Hello.h&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
...
extern&amp;nbsp;&amp;nbsp;&amp;nbsp; int aVariable;
...
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And, of course, Main.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
...
#include "Hello.h"
...

void MyFunc(void)
{
...
&amp;nbsp;&amp;nbsp;&amp;nbsp; aVariable = 1492; // set foreign variable
...
}
...
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Such constructs build and link for me [IDE 7.5]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps you made it 'static' by mistake?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:41:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564132#M17423</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564133#M17424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpcxpresso-support on Wed Jan 21 00:48:00 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is as MikeSimmonds says. You have declared ulDebug1 in hello.h (extern unlsigned long ulDebug1) but you have not defined it in hello.c (i.e. add unsigned long ulDebug1).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MikeSimmonds Note: You should never define a variable in a header - every time you include the header it will be redefined, resulting in multiple copies of the variable with the same name. Only ever declare variables in headers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww-ee.eng.hawaii.edu%2F%7Etep%2FEE160%2FBook%2Fchap14%2Fsubsection2.1.1.4.html" rel="nofollow" target="_blank"&gt;http://www-ee.eng.hawaii.edu/~tep/EE160/Book/chap14/subsection2.1.1.4.html&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for an explanation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:41:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564133#M17424</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Linker error</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564134#M17425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Dave Such on Thu Jan 22 08:30:19 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply's.&amp;nbsp; Yes, as suggested, it does now build.&amp;nbsp; So I changed the test program to more closely represent the method our projects are coded and it builds as well.&amp;nbsp; At least I can eliminate that as the problem.&amp;nbsp; Back to grabbing the shovel and keep digging.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've attached the new test program if anyone is interested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:41:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Linker-error/m-p/564134#M17425</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:41:03Z</dc:date>
    </item>
  </channel>
</rss>

