Skip to main content
Associate III
June 26, 2024
Question

undefined reference to `osDelay'/`osThreadSuspend'/`osSemaphoreAcquire'

  • June 26, 2024
  • 4 replies
  • 4780 views

Hi guys,

I'm stuck in the following issue. In my STM32 project I'm using FreeRTOS which I have enabled using CubeMX. In my project tree I have the following files:

Lyap94_0-1719407881182.png

At the same time I have included the following paths:

Lyap94_1-1719407980680.png

When I check the file with the error and try to find the referenece the header file is found and opened normally. All the .c files are in place as you can see.

 

Do you know what could be the issue?

This topic has been closed for replies.

4 replies

Andrew Neil
Super User
June 26, 2024

"undefined reference" is a linker error.

It means that you have omitted to provide a definition of that function - either as source code, or as a pre-built binary library.

Probably, you have #included a header which just declares that function (ie, just provides a prototype) - hence the compiler is happy - but haven't added the necessary source or pre-built binary library to your project - so the link fails.

 


@Lyap94 wrote:

 All the .c files are in place as you can see.


So which of them contains a definition of osDelay and/or osThreadSuspend and/or osSemaphoreAcquire ?

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Lyap94Author
Associate III
June 26, 2024

Hi Andrew Neil,

Thanks for the fast reply!

The file cmsis_os2.c includes the definition of all the functions that seem to be undefined. It's in Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2.

 

 

Andrew Neil
Super User
June 26, 2024

@Lyap94 wrote:

The file cmsis_os2.c includes the definition of all the functions that seem to be undefined. 


You screenshot is a bit low-res to see clearly, but it looks like that file has errors:

AndrewNeil_1-1719409154650.png

So maybe it wasn't (successfully) built ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Lyap94Author
Associate III
June 26, 2024

You are right. There are two files that have errors: 

- cmsis_os2.c --> SemaphoreHandle_t and QueueHandle_t could not be resolved 

- semphr.h --> Where typedef QueueHandle_t SemaphoreHandle_t; is defined

The problem starts there I think because the QueueHandle_t cannot be resolved. It is defined in queue.h which is also included...