undefined reference to 'mq_open'

验证 UNPv2里的一个例子时,连接时出现 undefined reference to ‘mq_open‘ 错误。

man mq_open ,发现里面有这么一句话 :link with -lrt 。加上 -lrt 后,连接成功。

运行,出现 Permission deny。继续查,man mq_overview 发现: Each message queue is identified by a name of the form /somename. 也就是说在指定 mqueue 的名字时,必须以 ”/" 开头,并且名字中只能有一个 “/"。UNPv2的 2.2 IPC names有详细的解释。

终于运行成功了,却发现找不到创建的 mqueue , 继续 man mq_overview。发现下面一段:

Mounting the message queue file system
       On Linux, message queues are created in a virtual file system. (Other implementations may also provide such a feature, but the details are likely to differ.) This file system can be mounted using the following commands:

$ mkdir /dev/mqueue
           $ mount -t mqueue none /dev/mqueue

The sticky bit is automatically enabled on the mount directory.

After the file system has been mounted, the message queues on the system can be viewed and manipulated using the commands usually used for files (e.g., ls(1) and rm(1)).

The contents of each file in the directory consist of a single line containing information about the queue:

$ ls /dev/mqueue/mymq
           QSIZE:129     NOTIFY:2    SIGNO:0    NOTIFY_PID:8260
           $ mount -t mqueue none /dev/mqueue

These fields are as follows:

 QSIZE Number of bytes of data in all messages in the queue.

NOTIFY_PID
              If this is non-zero, then the process with this PID has used mq_notify(3) to register for asynchronous message notification, and the remaining fields describe how notification occurs.

NOTIFY Notification method: 0 is SIGEV_SIGNAL; 1 is SIGEV_NONE; and 2 is SIGEV_THREAD.

SIGNO Signal number to be used for SIGEV_SIGNAL.

undefined reference to 'mq_open'

时间: 2024-08-25 00:38:18

undefined reference to 'mq_open'的相关文章

caffe日常坑系列之:undefined reference to symbol '_ZN2cv6String10deallocateEv'

在使用caffe库编译C++时出现的 解决如下: /usr/bin/ld: /tmp/ccA5JGRP.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'//usr/local/lib/libopencv_core.so.3.2: error adding symbols: DSO missing from command line解决:sudo apt-get autoremove libopencv-dev caffe

在codeblocks 下,C++编译不成功一直出现“undefined reference to `std::cout'|

自己搞了好久才知道,编辑c++,要用g++ 希望对大家有帮助 在codeblocks 下,C++编译不成功一直出现"undefined reference to `std::cout'|

Linux下运行《UNIX环境高级编程》undefined reference to `err_quit 编译出错的处理方法

错误信息: : undefined reference to `err_quit': undefined reference to `err_sys' 解决方法: 因为err_quit跟err_sys是作者自己定义的错误处理函数.所以最简单的解决办法是修改下apue.h文件,如下 /* * Our own header, to be included before all standard system headers. */ #ifndef _APUE_H #define _APUE_H #d

lua-5.2.3编译问题记录"libreadline.so: undefined reference to `PC'"

作者:zhanhailiang 日期:2014-10-21 [root@~/software]# cd lua-5.2.3 [root@~/software/lua-5.2.3]# make linux cd src && make linux make[1]: Entering directory `/root/software/lua-5.2.3/src' make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,

编译busybox遇到mount.c:(.text.nfsmount+0x): undefined reference to

如下: mount.c:(.text.nfsmount+0xa68): undefined reference to `authunix_create_default' mount.c:(.text.nfsmount+0xaeb): undefined reference to `clnt_sperror' mount.c:(.text.nfsmount+0xb12): undefined reference to `clnt_sperror' mount.c:(.text.nfsmount+0

undefined reference to `sin'问题解决

作者:zhanhailiang 日期:2014-10-25 使用gcc编译例如以下代码时报"undefined reference to `sin'": #include <stdio.h> #include <math.h> #include <stdlib.h>   main () { double a = sin(1); exit (0); } [root@~/wade/codeReview/learningc/9]# gcc -o timet

Linux下编译程序时,经常会遇到“undefined reference to XXX” 报错,

Linux下编译程序时,经常会遇到“undefined reference to XXX” 报错, 这里总结一些可能的原因和解决方案,给需要的朋友: 说道undefined reference error,先提一下Linux gcc链接规则: 链接的时候查找顺序是: -L 指定的路径, 从左到右依次查找 由 环境变量 LIBRARY_PATH 指定的路径,使用":"分割从左到右依次查找 /etc/ld.so.conf 指定的路径顺序 /lib 和 /usr/lib (64位下是/lib

undefined reference to `__sync_bool_compare_and_swap_4

然后开始glibc的编译工作. 你必须设定march这个参数才行,要不然会出现“undefined reference to `__sync_bool_compare_and_swap_4′.”这个错误 Core 2 Duo, GCC 4.2,CFLAGS 添加 -march=nocona -mtune=generic. 如果是GCC 4.1,Core Solo/Duo使用-march=prescott: Core 2 Duo/Solo则使用-march=nocona. i686等类似设置,例如

nios ii 13 主程序的函数可以用Open Declaration 查看,但是编译的时候却说 undefined reference to 。。。这是为什么?

在做12864 ip 核试验时,写了三个文件第一个是时序文件QC12864.v第二个是QC12864.H这个文件主要包括声明和宏定义,第三个文件是QC12864.c这个文件包含函数的定义.详细的请看 http://www.cnblogs.com/yuphone/archive/2010/03/25/1694547.html.我出现这个错误后把三个文件和成一个文件编译的时候,编译错误就发生了变化.把原来所指向的错误更加的细化.指向了原来错误那一行所包含的隐含信息.原来我在文件中出现了许多的语法错误