Posix_GCC_Simulator_6.0.4 Build Failure of "Smoke Test" FreeRTOS_Posix Under Linux

Finished building: ../AsyncIO/PosixMessageQueueIPC.c
Building target: FreeRTOS_Posix
Invoking: GCC C Linker
gcc -pthread -lrt -o"FreeRTOS_Posix" ./main.o ./ParTest/ParTest.o ./FreeRTOS_Kernel/croutine.o ./FreeRTOS_Kernel/list.o ./FreeRTOS_Kernel/queue.o ./FreeRTOS_Kernel/tasks.o ./FreeRTOS_Kernel/portable/MemMang/heap_3.o ./FreeRTOS_Kernel/portable/GCC/Posix/port.o ./FileIO/fileIO.o ./Common_Demo/Minimal/GenQTest.o ./Common_Demo/Minimal/QPeek.o ./Common_Demo/Minimal/blocktim.o ./Common_Demo/Minimal/countsem.o ./Common_Demo/Minimal/crflash.o ./Common_Demo/Minimal/crhook.o ./Common_Demo/Minimal/recmutex.o ./Common_Demo/Full/BlockQ.o ./Common_Demo/Full/PollQ.o ./Common_Demo/Full/death.o ./Common_Demo/Full/dynamic.o ./Common_Demo/Full/events.o ./Common_Demo/Full/flash.o ./Common_Demo/Full/flop.o ./Common_Demo/Full/integer.o ./Common_Demo/Full/print.o ./Common_Demo/Full/semtest.o ./AsyncIO/AsyncIO.o ./AsyncIO/AsyncIOSerial.o ./AsyncIO/AsyncIOSocket.o ./AsyncIO/PosixMessageQueueIPC.o

    ./AsyncIO/PosixMessageQueueIPC.o: In function `xPosixIPCOpen':
    PosixMessageQueueIPC.c:(.text+0x25): undefined reference to `mq_open'
    PosixMessageQueueIPC.c:(.text+0x106): undefined reference to `mq_notify'
    PosixMessageQueueIPC.c:(.text+0x126): undefined reference to `mq_unlink'
    ./AsyncIO/PosixMessageQueueIPC.o: In function `vPosixIPCClose':
    PosixMessageQueueIPC.c:(.text+0x185): undefined reference to `mq_close'
    ./AsyncIO/PosixMessageQueueIPC.o: In function `lPosixIPCSendMessage':
    PosixMessageQueueIPC.c:(.text+0x1d4): undefined reference to `mq_send'
    ./AsyncIO/PosixMessageQueueIPC.o: In function `lPosixIPCReceiveMessage':
    PosixMessageQueueIPC.c:(.text+0x218): undefined reference to `mq_receive'
    ./AsyncIO/PosixMessageQueueIPC.o: In function `prvPosixIPCInterruptHandler':
    PosixMessageQueueIPC.c:(.text+0x394): undefined reference to `mq_notify'
    ./AsyncIO/PosixMessageQueueIPC.o: In function `vPosixIPCEmpty':
    PosixMessageQueueIPC.c:(.text+0x442): undefined reference to `mq_receive'
    ./AsyncIO/PosixMessageQueueIPC.o: In function `vPosixIPCClose':
    PosixMessageQueueIPC.c:(.text+0x193): undefined reference to `mq_unlink'
    collect2: error: ld returned 1 exit status
    make: *** [FreeRTOS_Posix] Error 1

Build fails under Ubuntu 18.04, both native and under the Windows Subsystem for Linux (WSL), when trying to build either the “Release” or “Debug” versions of the “FreeRTOS_Posix” smoke-test program, using GCC “make” and “makefile” in either folder (i.e., in release folder “Posix_GCC_Simulator_6.0.4/Posix_GCC_Simulator/FreeRTOS_Posix/”).

Fixed by moving the “-lrt” switch to the end of the “gcc” command line, in the file “makefile”, which now reads:

gcc -pthread -o"FreeRTOS_Posix" $(OBJS) $(USER_OBJS) $(LIBS) -lrt

This issue seems to be over 5 years old!

Hi Bruce,

I want to make sure I am looking in the same place you are, it sounds like you are using the Posix simulator form the interactive site which was contributed by William Davy? I think that is a bit older than 5 years ! I do not see any updates to that since 2010.

Although that port has been very helpful to many people over the years it has some shortcomings, many of which have been improved upon in the port submitted by David Vrabel in March in this pull request https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/30 . Depending on what you are trying to do here I would probably recommend that you look at this much newer port instead.

You can find the new port in the portable folder under ThirdParty on the master branch in GitHub over here https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/master/portable/ThirdParty/GCC/Posix

This is based on the William Davy version and is much more likely to be up to date and behave a lot more like FreeRTOS does on a Microcontroller.

1 Like


Thank you for the prompt and knowledgeable explanation—and recommendations. I was just following the link from this page, which I found with a Google search for “FreeRTOS Unix”…


Over the last 20+ years I’ve personally created a number of commercially successful STM32-based telematics devices (both hardware and firmware) for hire, all based on FreeRTOS, numbering into the low 7 figures of installed base. All of my delivered hardware/firmware designs have had an accompanying Windows FreeRTOS port, emulating the actual hardware. I always develop/debug using the FreeRTOS Windows simulator and then port to the real telematics hardware AFTER the hardware is ready. My typical time from first-article to running firmware is measured in days. My customers like that a lot.

Anyway, that’s why I know and love the FreeRTOS Windows simulator. I’ve recently been looking into supporting the same under MacOS, Linux, and/or Windows WSL. I typically deliver a rich set of automated regression tests that run under the FreeRTOS Windows simulator, running at speeds much, much faster than real-time—typically 1000x real-time. I’m hoping that maybe the FreeRTOS simulator based on Linux threads will have better throughput.

I will take a look at the GitHub Third Party branch link that you provided.

I do remain baffled by the fact that the FreeRTOS Website points everyone at the now-ancient Posix/Linux Simulator FreeRTOS port. Clearly, I have a bit of GitHub homework to do!

Best regards,


That sounds like a sound and wise approach!

Let’s see if I can un-baffle you there, the website is pointing to latest released/albeit old implementation. The port I pointed out was submitted just after the last FreeRTOS release, next one will be coming up soon and then the docs will also be pointing to it.

1 Like