Search code examples
c++freertos

Eclipse C++ unable to compile, undefined reference to 'xTaskCreate'


I am trying to move my project to Eclipse (from platformio). I want to pull in some libraries, but I am failing to setup the environment properly to get things compiled.

in my main.cpp I have the following includes:

extern "C"
{
    #include <stdio.h>
    #include "board.h"
    #include "peripherals.h"
    #include "pin_mux.h"
    #include "clock_config.h"
    #include "MIMXRT1021.h"

    #include "FreeRTOS.h"
    #include "task.h" // <== contains the macro BaseType_t xTaskCreate(....)
}

And then the following code

void Test(void *vParameters)
{

}

int main(void) {

    /* Init board hardware. */
    BOARD_ConfigMPU();
    BOARD_InitBootPins();
    BOARD_InitBootClocks();
    BOARD_InitBootPeripherals();

    xTaskCreate(
            Test,
            "bla",
            100,
            nullptr,
            1,
            nullptr);

    while(1) {}
    
    return 0 ;
}

This gives the following compile error:

C:\Users\baprins\Documents\MCUXpressoIDE_11.3.1_5262\workspace\iobox\Debug/../source/iobox.cpp:64: undefined reference to `xTaskCreate'

I did add the include paths :

enter image description here

What am I missing?


Solution

  • As always... once you know what to do, it's really simple ;-)

    Go to

    • project properties
    • C/C+ General
    • Paths and Symbols

    In the source location tab, add a location where you want to store your libraries. E.g.

    enter image description here

    I added a "link" and just typed in the name "libraries". Which felt a bit counter intuitive, maybe it can be done more straight forward. The "add folder" button didn't seem to allow to create a new folder.

    Anyway, next step is to simply add all include paths in the includes tab.

    enter image description here

    I am not sure if / when it's necessary, but I added the paths for all configs, all languages. That seems to work fine.

    enter image description here