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.
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.
Are there some compiler/linker settings that I need to modify to allow the recognition of C++ and linkage?
mqx_tasks.c:
void func(int)'
void Task1_task(uint32_t task_init_data)
{
int counter = 0;
while(1) {
counter++;
func(2);
}
}
run.cpp:
extern "C" void func(int val) {
int i=0;
i = i + val;
}
Hello George:
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.
However, if you are using the ARM GCC build tools, our colleague Erich Styger already posted a very detailed tutorial to achieve this:
Processor Expert, gcc C++ and Kinetis-L with MQXLite | MCU on Eclipse
I think you will find the solution by following his instructions.
Regards!
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------