# undefined reference to '\_xQueueCreateMutex'

**URL:** <https://forums.freertos.org/t/undefined-reference-to-xqueuecreatemutex/5915>\
**Category:** Kernel\
**Created:** [April 28, 2016, 9:33am UTC](https://forums.freertos.org/t/undefined-reference-to-xqueuecreatemutex/5915 "2016-04-28T09:33:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 28, 2016, 9:33am UTC](https://forums.freertos.org/t/undefined-reference-to-xqueuecreatemutex/5915/1 "2016-04-28T09:33:24Z")

</div>

**[ady001](https://sourceforge.net/u/ady001/)** wrote on [Thursday, April 28, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/40521010/#cfa9):

Dear Support,  
I’ve been evaluating the RTOS on the PIC24 platform and have been impressed. I’ve got tasks with priorities, messages queues, critical sections etc.

I wanted to have a play with a Mutex but the linker does not seem to like xSemaphoreCreateMutex() even though it is happy with my later use of xSemaphoreGive() and xSemaphoreTake() in the same file. Maybe I’ve missed a header file or a defintion somewhere but I’m stuck.

/\* My includes \*/  
include “FreeRTOS.h”  
include “task.h”  
include “semphr.h”  
include “queue.h”

/\* My Mutex handle \*/  
static SemaphoreHandle\_t MutexHandle\_AppTestLED = NULL;

/\* My Mutex creation \*/  
void vApplicationMutex(void)  
{  
MutexHandle\_AppTestLED = xSemaphoreCreateMutex();  
}

// Error thrown by the linker…  
: In function `_vApplicationMutex': : undefined reference to `\_xQueueCreateMutex’  
build/default/production/\_ext/1472/ApplicationTask.o(.text+0x12): In function `_vApplicationMutex': : undefined reference to `\_xQueueCreateMutex’

The function xSemaphoreCreateMutex() is in blue in the project, showing it is recognize as a function and ‘Navigate to defintion’ opens the file semphr.h at the extract below ( where the section is active in the compilation ).

if( configSUPPORT\_DYNAMIC\_ALLOCATION == 1 )  
define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE\_TYPE\_MUTEX )  
endif

Please can you help ?

Kind regards,  
Ady

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 28, 2016, 9:53am UTC](https://forums.freertos.org/t/undefined-reference-to-xqueuecreatemutex/5915/2 "2016-04-28T09:53:36Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Thursday, April 28, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/40521010/#71e1):

Is configUSE\_MUTEXES set to 1 in FreeRTOSConfig.h?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 28, 2016, 10:06am UTC](https://forums.freertos.org/t/undefined-reference-to-xqueuecreatemutex/5915/3 "2016-04-28T10:06:16Z")

</div>

**[ady001](https://sourceforge.net/u/ady001/)** wrote on [Thursday, April 28, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/40521010/#66a5):

Many thanks that has solved it.  
In fact configUSE\_MUTEXES was not in FreeRTOSConfig.h at all else I would have given it a try !  
I’d expect all configurable options to be in this file ?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [April 28, 2016, 10:10am UTC](https://forums.freertos.org/t/undefined-reference-to-xqueuecreatemutex/5915/4 "2016-04-28T10:10:41Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, April 28, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/40521010/#66a5/b846):

That is quite an old demo, perhaps even created before there were  
mutexes? [http://www.freertos.org/a00110.html](http://www.freertos.org/a00110.html)

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 28, 2016, 10:20am UTC](https://forums.freertos.org/t/undefined-reference-to-xqueuecreatemutex/5915/5 "2016-04-28T10:20:10Z")

</div>

**[ady001](https://sourceforge.net/u/ady001/)** wrote on [Thursday, April 28, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/40521010/#5767):

OK fair enough. I used the demo to get up and running, I’ll look for the latest FreeRTOS source.
