UNIX网络编程 卷2 源代码使用
[root@localhost myunp2]# vim ftok.c
[root@localhost myunp2]# gcc -o ftok ftok.c
/tmp/ccxRydhw.o: In function `main':
ftok.c:(.text+0x18): undefined reference to `err_quit'
ftok.c:(.text+0x30): undefined reference to `Stat'
ftok.c:(.text+0x48): undefined reference to `Ftok'
collect2: 错误:ld 返回
[root@localhost myunp2]# gcc -o ftok ftok.c -lunpipc
/usr/lib/libunpipc.a(wrapunix.o): In function `Mq_open':
wrapunix.c:(.text+0x4d8): undefined reference to `mq_open'
wrapunix.c:(.text+0x4f0): undefined reference to `mq_open'
/usr/lib/libunpipc.a(wrapunix.o): In function `Mq_close':
wrapunix.c:(.text+0x52b): undefined reference to `mq_close'
/usr/lib/libunpipc.a(wrapunix.o): In function `Mq_unlink':
wrapunix.c:(.text+0x55b): undefined reference to `mq_unlink'
/usr/lib/libunpipc.a(wrapunix.o): In function `Mq_send':
wrapunix.c:(.text+0x5a3): undefined reference to `mq_send'
/usr/lib/libunpipc.a(wrapunix.o): In function `Mq_receive':
wrapunix.c:(.text+0x5e3): undefined reference to `mq_receive'
/usr/lib/libunpipc.a(wrapunix.o): In function `Mq_notify':
wrapunix.c:(.text+0x623): undefined reference to `mq_notify'
/usr/lib/libunpipc.a(wrapunix.o): In function `Mq_getattr':
wrapunix.c:(.text+0x653): undefined reference to `mq_getattr'
/usr/lib/libunpipc.a(wrapunix.o): In function `Mq_setattr':
wrapunix.c:(.text+0x68b): undefined reference to `mq_setattr'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_open':
wrapunix.c:(.text+0x9c8): undefined reference to `sem_open'
wrapunix.c:(.text+0x9e0): undefined reference to `sem_open'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_close':
wrapunix.c:(.text+0xa1b): undefined reference to `sem_close'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_unlink':
wrapunix.c:(.text+0xa4b): undefined reference to `sem_unlink'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_init':
wrapunix.c:(.text+0xa8b): undefined reference to `sem_init'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_destroy':
wrapunix.c:(.text+0xabb): undefined reference to `sem_destroy'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_wait':
wrapunix.c:(.text+0xaeb): undefined reference to `sem_wait'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_trywait':
wrapunix.c:(.text+0xb1c): undefined reference to `sem_trywait'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_post':
wrapunix.c:(.text+0xb5b): undefined reference to `sem_post'
/usr/lib/libunpipc.a(wrapunix.o): In function `Sem_getvalue':
wrapunix.c:(.text+0xb93): undefined reference to `sem_getvalue'
/usr/lib/libunpipc.a(wrapunix.o): In function `Shm_open':
wrapunix.c:(.text+0xccc): undefined reference to `shm_open'
/usr/lib/libunpipc.a(wrapunix.o): In function `Shm_unlink':
wrapunix.c:(.text+0xd0b): undefined reference to `shm_unlink'
collect2: 错误:ld 返回
[root@localhost myunp2]# gcc -lrt -o ftok ftok.c -lunpipc
[root@localhost myunp2]# man mq_open
Cannot open the message catalog "man" for locale "zh_CN.UTF-8"
(NLSPATH="/usr/share/locale/%l/LC_MESSAGES/%N") Formatting page, please wait...
出现上面的错误,使用gcc 加选项-lrt解决。
错误:
[root@localhost myunp2]# gcc -lrt -o slot slot.c -lunpipc
slot.c: 在函数‘main’中:
slot.c::: 错误:‘IPC_PRIVATE’未声明(在此函数内第一次使用)
msqid=Msgget(IPC_PRIVATE,SVMSG_MODE|IPC_CREAT);
^
slot.c::: 附注:每个未声明的标识符在其出现的函数内只报告一次
In file included from slot.c:::
unpipc.h::: 错误:‘MSG_R’未声明(在此函数内第一次使用)
#define SVMSG_MODE (MSG_R | MSG_W | MSG_R>>3 | MSG_R>>6)
^
slot.c::: 附注:in expansion of macro ‘SVMSG_MODE’
msqid=Msgget(IPC_PRIVATE,SVMSG_MODE|IPC_CREAT);
^
unpipc.h::: 错误:‘MSG_W’未声明(在此函数内第一次使用)
#define SVMSG_MODE (MSG_R | MSG_W | MSG_R>>3 | MSG_R>>6)
^
slot.c::: 附注:in expansion of macro ‘SVMSG_MODE’
msqid=Msgget(IPC_PRIVATE,SVMSG_MODE|IPC_CREAT);
^
slot.c::: 错误:‘IPC_CREAT’未声明(在此函数内第一次使用)
msqid=Msgget(IPC_PRIVATE,SVMSG_MODE|IPC_CREAT);
^
slot.c::: 错误:‘IPC_RMID’未声明(在此函数内第一次使用)
Msgctl(msqid,IPC_RMID,NULL);
解决方法:
1.unpv22e里面的Make.defines
修改
#CFLAGS = -g -O2 -D_REENTRANT -Wall
CFLAGS = -g -O2 -D_GNU_SOURCE -D__USE_GNU -D_REENTRANT -Wall
2 将unpv22e中的unpipc.h拷贝到需要编译的代码的目录。
3 将config.h也拷贝到这个目录,由于unpipc.h依赖于这个头文件。
UNIX网络编程 卷2 源代码使用的更多相关文章
- [转载] 读《UNIX网络编程 卷1:套接字联网API》
原文: http://cstdlib.com/tech/2014/10/09/read-unix-network-programming-1/ 文章写的很清楚, 适合初学者 最近看了<UNIX网 ...
- UNIX网络编程 卷2:进程间通信
这篇是计算机类的优质预售推荐>>>><UNIX网络编程 卷2:进程间通信(第2版)> UNIX和网络专家W. Richard Stevens的传世之作 编辑推荐 两 ...
- 《UNIX网络编程 卷1》之"学习环境搭建"(CentOS 7)
<UNIX网络编程 卷1>的源码可以从www.unpbook.com下载得到.解压之后的目录为unpv13e. 详细步骤 编译 进入unpv13e目录,按如下步骤编译: ./configu ...
- UNIX网络编程卷1 - >环境搭建(ubuntu16.04)
学习unp网络编程,树上的例子均存在#include“unp.h”,故需要对环境进行配置. 1.到资源页下载www.unpbook.com 2.解压并将unpv13e移动到相应的文件夹下 (因为我 ...
- 【unp】unix网络编程卷1-->环境搭建(ubuntu14.04)
学习unp网络编程,树上的例子均存在#include "unp.h",故需要对环境进行配置. 1. 到资源页下载unpv13e 2. 解压并将unpv13e 移动到相应的文件夹下 ...
- 《UNIX网络编程 卷1:套接字联网API》读书笔记(一):网络编程简介
概述 要编写通过计算机网络通信的程序,首先要确定这些程序相互通信所用的协议.大多数网络是按照划分成客户和服务器来组织的.本章及后续章节的焦点是TCP/IP协议族,也可称为网际协议族.下图为客户与服务器 ...
- 《Unix网络编程卷1:套接字联网API》读书笔记
第一部分:简介和TCP/IP 第1章:简介 第2章:传输层:TCP.UDP和SCTP TCP:传输控制协议,复杂.可靠.面向连接协议 UDP:用户数据报协议,简单.不可靠.无连接协议 SCTP:流控制 ...
- UNIX网络编程卷1 第一章 简介 读书笔记。
基本没讲什么,一点点计算机网络发展史,一点点socket()简单介绍,最重要的是1.3节协议无关性. 协议无关性: 贯穿整本书的一个重要特性,他主要强调的是 socket是网络协议无关的编程接口. s ...
- UNIX网络编程卷2进程间通信读书笔记(二)—管道 (1)
一.管道 管道的名称很形象,它就像是一个水管,我们从一端到水然后水从令一端流出.不同的是这里说的管道的两边都是进程.从一端往管道里写数据,其它进程可以从管道的另一端的把数据读出,从而实现了进程间通信的 ...
随机推荐
- cocos2d-x学习笔记--第一天记录
1.环境安装 http://www.cocos2d-x.org/ ---下载2.2.3--解压 https://www.python.org/ ---2.7.6 系统环境变量 设置安装目录 2创建一个 ...
- MySql 缓存查询原理与缓存监控 和 索引监控
MySql缓存查询原理与缓存监控 And 索引监控 by:授客 QQ:1033553122 查询缓存 1.查询缓存操作原理 mysql执行查询语句之前,把查询语句同查询缓存中的语句进行比较,且是按字节 ...
- git报错:Pull is not possible because you have unmerged files解决方法
在git pull的过程中,如果有冲突,那么除了冲突的文件之外,其它的文件都会做为staged区的文件保存起来. 重现: $ git pull A Applications/Commerce/B ...
- 打包jar问题
一. 先说一下一般是动态布局最好,效率高,动态就是java写布局,这是 老外的专长,一般res目录是不能打包的,布局动态写,其余的就是图片什么的了,可以建一个assess文件夹,把图片放里面,打jar ...
- 微信小程序接入腾讯云IM即时通讯(会话列表)
会话列表功能概述: 登录 :先用自己的账号登录腾讯云: 获取会话列表 :登录之后再获取会话列表: 更新未读消息数量 :获取会话列表之后更新未读消息数量 WXML代码(自己写的将就看一下) <vi ...
- JQuery 简单表格验证
<form action="{% url 'register' %}" method="post"> 用户名:<input id=" ...
- Redis redis-trib集群配置
redis文档:http://doc.redisfans.com/ 参考:https://www.cnblogs.com/wuxl360/p/5920330.html http://www.cnblo ...
- JavaScript Web 应用最佳实践分析
[编者按]本文作者为 Mathias Schäfer,旨在回顾在客户端大量使用JavaScript 的最佳 Web应用实践.文章系国内 ITOM 管理平台 OneAPM 编译呈现. 对笔者来说,Jav ...
- 使用ember-cli脚手架快速构建项目
步骤: 安装Ember. 创建一个新应用程序. 定义路由. 编写一个UI组件. 构建您的应用程序以部署到生产环境. 安装Ember 您可以使用npm(Node.js包管理器,你需要安装node.js) ...
- leetCode题解之旋转数字
1.题目描述 X is a good number if after rotating each digit individually by 180 degrees, we get a valid n ...