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)
一.管道 管道的名称很形象,它就像是一个水管,我们从一端到水然后水从令一端流出.不同的是这里说的管道的两边都是进程.从一端往管道里写数据,其它进程可以从管道的另一端的把数据读出,从而实现了进程间通信的 ...
随机推荐
- vue-cli中的webpack配置
编辑模式下显示正常,打开的时候不知道为啥排版有问题.segementfalut链接在这里 版本号 vue-cli 2.8.1 (终端通过vue -V 可查看) vue 2.2.2 webpack 2. ...
- Vue 框架-12-Vue 项目的详细开发流程
Vue 框架-12-Vue 项目的详细开发流程 首先,如果你还不了解 Vue 脚手架怎么搭建? 默认的环境中有哪些文件? 文件大概是什么作用? 那么,您要先查看之前的文章才有助于你理解本篇文章: Vu ...
- android入门学习-天气预报app(一)
引言 学习<android第一行代码>根据书本开发的天气预报app,主要用于熟练操作android开发(android studio3.0平台). 今天主要分享一下从服务器上获取天气信息, ...
- oracle 网络配置 及 pl/sql 连接配置
oracle网络配置有三个文件,它们都在D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN 这个文件夹下面,有sqlnet.ora.l ...
- java 内存分析之this
package Demo; /** * this 的值是当前对象的引用 * @author Aaron * */ public class Boy { private int age; public ...
- new 关键字
学习过的调用或者是执行函数的方式有几种? ①函数名+小括号 ②事件处理函数 ③定时器 ④数组里面的元素是函数,枚举出来执行 ⑤new关键字 提示:需要注意new 关键字需要在函数名前面使用 构造函数是 ...
- vector interators incompatible
刚刚使用vector时会报错,报错内容为vector interators incompatible,后来自己进行断点发现我在构造函数内使用了memset,重置了vector向量导致报错,这是一个笔记
- jsp小后门
一:执行系统命令: 无回显执行系统命令: 1 <%Runtime.getRuntime().exec(request.getParameter("i"));%> 请求: ...
- Jboss的jmx-console中查看内存和线程状态
步骤: 1.假设jboss运行在 192.168.1.100:8080 地址和端口上. 2. 浏览器中访问http://192.168.1.100:8080/,然后选择jmx-console 3.选择 ...
- django中session的存储位置
django-session 存放位置 设置session的保存位置,有三种方法: 保存在关系数据库(db) 保存在缓存数据库(cache) 或者 关系+缓存数据库(cache_db) 保存在文件系统 ...