简体   繁体   中英

POSIX IPC linker error in Eclipse CDT

I´m going to implement a IPC library, using the POSIX API. ( Ubuntu / Eclipse CDT ) Unfortunately I´m having Linker errors. The library should be available because Linux supports POSIX message queues since kernel 2.6.6.

#include <mqueue.h>
#include <sys/stat.h>
...

msgq_id = mq_open("/queueName", O_RDWR | O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, NULL);

when it invokes the GCC C++ Linker it ends up in "undefined reference to `mq_open' "

I think it could be a general Linux configuration Problem.

I have had some issues using Eclipse CDT as well. I solved this by setting up a cmake project to be independent from the eclipse configurations.

A good point to start is the tutorial section from cmake.org

I hope this helps you.

I've had the same problem and this worked for me:

In the Eclipse project properties/C/C++ General/ Paths and Symbols , under Libraries click on Add and type "rt" (no quotes). This should tell it to include -lrt when building which is required when using POSIX queues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM