程式語言 - GNU - 解決Undefined reference to mq_timedreceive問題



參考資訊:
https://stackoverflow.com/questions/19423567/message-queue-makefile-error-undefined-reference-to-mq-open/48476980

問題如下:

  LINK  i386-linux-user/qemu-i386
syscall.o: In function `do_syscall':
qemu/linux-user/syscall.c:7841: undefined reference to `mq_timedreceive'
qemu/linux-user/syscall.c:7866: undefined reference to `mq_setattr'
qemu/linux-user/syscall.c:7813: undefined reference to `mq_unlink'
qemu/linux-user/syscall.c:7824: undefined reference to `mq_timedsend'
syscall.o: In function `mq_open':
/usr/include/x86_64-linux-gnu/bits/mqueue2.h:56: undefined reference to `mq_open'
syscall.o: In function `do_syscall':
qemu/linux-user/syscall.c:7845: undefined reference to `mq_receive'
qemu/linux-user/syscall.c:7828: undefined reference to `mq_send'
qemu/linux-user/syscall.c:7861: undefined reference to `mq_getattr'
collect2: error: ld returned 1 exit status
Makefile:398: recipe for target 'qemu-i386' failed
make[1]: *** [qemu-i386] Error 1
Makefile:84: recipe for target 'subdir-i386-linux-user' failed
make: *** [subdir-i386-linux-user] Error 2

解法如下:

LIBS+= -lrt