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)
一.管道 管道的名称很形象,它就像是一个水管,我们从一端到水然后水从令一端流出.不同的是这里说的管道的两边都是进程.从一端往管道里写数据,其它进程可以从管道的另一端的把数据读出,从而实现了进程间通信的 ...
随机推荐
- Html 表单标签 Form
Html表单 #转载请留言联系 表单用于搜集不同类型的用户输入,表单由不同类型的标签组成,相关标签及属性用法如下: 1.<form>标签 定义整体的表单区域 action属性 定义表单数据 ...
- UpdateServer事务实现机制
UpdateServer(UPS) 是OceanBase的写入单点,一个集群中只有一台UPS服务器,所有的写都写入到这台机器.OceanBase采用基于静动态数据分离的机制,静态数据存储在静态数据服务 ...
- 微信网页IOS上传图片旋转解决方案
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- asp.net使用一般处理程序实现文件下载
首先有一个html页面,页面有一个链接,点击链接弹出文件下载/保存(类似迅雷下载链接) <!DOCTYPE html> <html> <head> <meta ...
- 名词解释:Linux内存管理之RSS和VSZ
Linux内存管理中不管是top命令还是pmap命令,都会有RSS和VSZ这两个名词,这里解释一下: RSS( Resident Set Size )常驻内存集合大小,表示相应进程在RAM中占用了多少 ...
- 卸载oracle 10g
1.开始->设置->控制面板->管理工具->服务——> 停止所有Oracle服务.(没有起动的就不用停用了)2.开始->程序->Oracle - OraD ...
- CSS学习摘要-盒子模型
注:全文摘要自网络开发者网站,当然间隔也会整理一些思路和格式排版添加进去. CSS框模型(译者注:也被称为"盒模型")是网页布局的基础 --每个元素被表示为一个矩形的方框,框的内容 ...
- php中查询时间
在做查询过程中,例如要实现查上个月从第一天到最后一天的佣金(提成),那我们在程序实现过程中就要让程序在上个月的范围内查询,第一天是比较好办,但最后一天就不定,要去写段函数进行月份及年份判断来得出上个月 ...
- JSTORM 问题排查
## 运行时topology的task列表中报"task is dead"错误有几个原因可能导致出现这个错误: 1. task心跳超时,导致nimbus主动kill这个task所在 ...
- libextobjc 实现的 defer
算法沉思录:分而治之(复用): 分而治之是指把大而复杂的问题分解成若干个简单的小问题,然后逐个解决.这种朴素的思想来源于人们生活与工作的经验,也完全适合于技术领域. 要崩溃的节奏: 要崩溃的节奏: V ...