Undefined reference to xTaskCreate()

I’m using PlatformIO to run a FreeRTOS code on the Nexys RISC-V framework. Shown below is the platformio.ini file:

platform = chipsalliance
board = swervolf_nexys
framework = wd-riscv-sdk, freertos
debug_tool = whisper

Here’s my program:

#include "FreeRTOS.h"

#include "task.h"

#include <bsp_printf.h>

#include <bsp_mem_map.h>

#include <bsp_version.h>

void vTask1(void *pvParameters);

void vTask2(void *pvParameters);

int main(void)



    xTaskCreate(&vTask1, "Task 1", 1024, NULL, 1, NULL);

    xTaskCreate(&vTask2, "Task 2", 1024, NULL, 1, NULL);


    return 0;


void vTask1(void *pvParameters)


    for (;;)


        printfNexys("Task 1\r\n");





void vTask2(void *pvParameters)


    for (;;)


        printfNexys("Task 2\r\n");





I’m getting the below error:
task_code.c:14: undefined reference to `xTaskCreate’

Please help me resolve this issue.

Undefined reference to xTaskCreate means you didn’t compile and link the related FreeRTOS source files (in this case tasks.c) to your program. You need to setup your build environment correctly.

To my knowledge the source files have been compiled. But where should they be located in PlatformIO to compile ?

Sorry - I’m not familiar with PlatformIO. But isn’t there a working demo you could check or use as starting point ?

Yes, there exists a working demo and that was running fine. However when I tried to compile my own code, I wasn’t able to.

The undefined reference error most likely comes from the linker, so you appear to have problems with your linker setup.

I don’t have much knowledge about the linker setup. Could you help me with that?

@vinceab : I found a demo for the same board over on this github.

Could you try replacing the following line in your platform.ini




Thanks much,

It’s still not compiling. The demo used in the GitHub repo. did not use the FreeRTOS header files. It created its own custom source files.

Do you have configSUPPORT_DYNAMIC_ALLOCATION set in your FreeRTOS config?

XTaskCreate()/xTaskGenericCreate() are base functions that are always included no matter what the configuration of the system so the only thing that comes to mind is that you are not building the source file that contains the function’s definition. Are you building FreeRTOS/Source/tasks.

This is not C++ code by any chance? If so you need to wrap your #includes into an extern “C” declaration.

XTaskCreate needs configSUPPORT_DYNAMIC_ALLOCATION = 1 (which is the default) to be present.

You also needs tasks.c to be part of the project.