<?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 Calling C++ function from mqx_tasks.c in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Calling-C-function-from-mqx-tasks-c/m-p/293851#M11944</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm running CW10.3 and I have an MQX-lite project for K20DN512VMD10. I'm trying to call a C++ function from the mqx_tasks.c Task1_task function.&lt;/P&gt;&lt;P&gt;I have declared a C++ function as extern "C" void func(int);, however I still am getting the error "undefined reference to 'func' in the mqx_tasks.c file.&lt;/P&gt;&lt;P&gt;Are there some compiler/linker settings that I need to modify to allow the recognition of C++ and linkage?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mqx_tasks.c:&lt;/P&gt;&lt;P&gt;void func(int)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void Task1_task(uint32_t task_init_data)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int counter = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter++;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; func(2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run.cpp:&lt;/P&gt;&lt;P&gt;extern "C" void func(int val) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i + val;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Mar 2014 18:43:16 GMT</pubDate>
    <dc:creator>gsosnow</dc:creator>
    <dc:date>2014-03-11T18:43:16Z</dc:date>
    <item>
      <title>Calling C++ function from mqx_tasks.c</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Calling-C-function-from-mqx-tasks-c/m-p/293851#M11944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm running CW10.3 and I have an MQX-lite project for K20DN512VMD10. I'm trying to call a C++ function from the mqx_tasks.c Task1_task function.&lt;/P&gt;&lt;P&gt;I have declared a C++ function as extern "C" void func(int);, however I still am getting the error "undefined reference to 'func' in the mqx_tasks.c file.&lt;/P&gt;&lt;P&gt;Are there some compiler/linker settings that I need to modify to allow the recognition of C++ and linkage?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mqx_tasks.c:&lt;/P&gt;&lt;P&gt;void func(int)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void Task1_task(uint32_t task_init_data)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int counter = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter++;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; func(2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run.cpp:&lt;/P&gt;&lt;P&gt;extern "C" void func(int val) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i + val;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 18:43:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Calling-C-function-from-mqx-tasks-c/m-p/293851#M11944</guid>
      <dc:creator>gsosnow</dc:creator>
      <dc:date>2014-03-11T18:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calling C++ function from mqx_tasks.c</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Calling-C-function-from-mqx-tasks-c/m-p/293852#M11945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello George:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MQX-Lite is managed as a Processor Expert component, and Processor Expert projects are not created with C++ support, the compiler is just for "C". This is why your function in run.cpp cannot be found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if you are using the ARM GCC build tools, our colleague Erich Styger already posted a very detailed tutorial to achieve this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://mcuoneclipse.com/2012/10/04/processor-expert-gcc-c-and-kinetis-l-and-mqxlite/" title="http://mcuoneclipse.com/2012/10/04/processor-expert-gcc-c-and-kinetis-l-and-mqxlite/"&gt;Processor Expert, gcc C++ and Kinetis-L with MQXLite | MCU on Eclipse&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you will find the solution by following his instructions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;Jorge Gonzalez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 01:19:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Calling-C-function-from-mqx-tasks-c/m-p/293852#M11945</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2014-03-12T01:19:06Z</dc:date>
    </item>
  </channel>
</rss>

