I'm writing unit tests for a project in C using Throw The Switch's Ceedling/Unity/CMock combo as the unit testing framework.
I've run into an interesting dilemma where I'm using mqueue.h in one of my unit tests. When the tests compile, I get gcc linker undefined reference errors for mq_open(), mq_close(), etc..
From what I understand, based on this finding the -lrt flag needs to go at the end of the gcc command--after listing sources (and executables?) gcc test_foo.c -lrt. Unfortunately, ceedling is written to put the flag right after the command: gcc -lrt test_foo.c, and I can't find a way to change the order.
The documentation supplied with Ceedling only covers how to add flags to the gcc command, not how to change the order. I've tried poking around in Ceedling's vast source code, but it's written in Ruby, which I'm unfamiliar with.
So my questions are:
- Does the placement of -lrt really effect the linking of mq_*()
- Any thoughts on how to change the placement of the -lrt flag?
Almost 3 years later had similar issue. They have added this feature in https://github.com/ThrowTheSwitch/Ceedling/issues/136, but usage is still not easy to understand from documentation. I needed to include math library (requires '-lm' flag in the end of command) and ended up with following config section (particularly system part):
For some reason ceedling did not add flags at all, when added to commons or particular build sections.