【发布时间】:2016-05-29 21:31:00
【问题描述】:
我在 Ubuntu 的 C 语言中的消息队列有问题。我使用 VirtualBox 来运行 Ubuntu。
我收到错误,即“未定义对 mq_open 的引用。ld 返回 1 个退出状态”。
我知道有一个与此相同的问题,但我尝试了该解决方案但没有奏效,所以我想再问一次。请帮忙!
这是我的代码,真的很简单,但我什至无法编译。
这是我的名字.c
#include <stdlib.h>
#include <mqueue.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include "sharedMsg.h"
int main()
{
mqd_t mq;
mq = mq_open(MQNAME, O_RDWR | O_CREAT, 0666, NULL);
}
这是我的 sharedMsg.h
struct item{
char *word;
int lineNum;
};
#define MQNAME "/sentmsg"
最后这是我的 MakeFile
all: deneme
deneme: deneme.c
gcc -g -Wall -o deneme deneme.c -lrt
clean:
rm -fr *~ *.o
【问题讨论】:
-
只是为了确定,你已经执行了
sudo apt-get install build-essential?你的 Makefile 坏了。all:需要deneme,但你提供了deneme1! -
是的,我执行了 build -essential 甚至再次确定,我输入这个并再次安装
标签: c ubuntu makefile message-queue