Q:

message queue makefile error: undefined reference to `mq_open'

Even though I have linked -lrt in my Makefile, as you can see below, I am still getting undefined reference to 'mq_open'. Please help!
all:get1 iserv1
get: get1.c
    gcc -Wall -o get1 get1.c -lrt
iserv: iserv1.c
    gcc -Wall -o iserv1 iserv1.c -lrt
clean:
    rm -fr *~ get1 iserv1

A:

Your makefile is wrong
all:get1 iserv1
get: get1.c
    gcc -Wall -o get1 get1.c -lrt

all has a prerequisite of get1 and iserv1. But you created a get target and an iserv target. So e.g. get1 will be compiled with the default make rules, which does not include -lrt (this should show if you look at the gcc commands that actually are executed.) 
Your makefile should like like this:
all:get1 iserv1
get1: get1.c
    gcc -Wall -o get1 get1.c -lrt
iserv1: iserv1.c
    gcc -Wall -o iserv1 iserv1.c -lrt
clean:
    rm -fr *~ get1 iserv1

A:

Note -lrt should be at end not inbetween.

