Linux - Unix环境高级编程(第三版) 源代码编译(即头文件apue.h如何使用问题)【转】
本文转载自:http://blog.csdn.net/hadas_wang/article/details/43203795
1. 下载代码:http://www.apuebook.com/code3e.html
2. 安装依赖库:sudo apt-get install libbsd-dev
3. 进入下载目录make
4. 复制头文件和动态链接库
- sudo cp ./include/apue.h /usr/include/
- sudo cp ./lib/libapue.a /usr/local/lib/
- sudo cp ./lib/libapue.a /usr/lib/
5. 设置错误文件error.h
- #include "apue.h"
- #include <errno.h> /* for definition of errno */
- #include <stdarg.h> /* ISO C variable aruments */
- static void err_doit(int, int, const char *, va_list);
- /*
- * Nonfatal error related to a system call.
- * Print a message and return.
- */
- void err_ret(const char *fmt, ...)
- {
- va_list ap;
- va_start(ap, fmt);
- err_doit(1, errno, fmt, ap);
- va_end(ap);
- }
- /*
- * Fatal error related to a system call.
- * Print a message and terminate.
- */
- void err_sys(const char *fmt, ...)
- {
- va_list ap;
- va_start(ap, fmt);
- err_doit(1, errno, fmt, ap);
- va_end(ap);
- exit(1);
- }
- /*
- * Fatal error unrelated to a system call.
- * Error code passed as explict parameter.
- * Print a message and terminate.
- */
- void err_exit(int error, const char *fmt, ...)
- {
- va_list ap;
- va_start(ap, fmt);
- err_doit(1, error, fmt, ap);
- va_end(ap);
- exit(1);
- }
- /*
- * Fatal error related to a system call.
- * Print a message, dump core, and terminate.
- */
- void err_dump(const char *fmt, ...)
- {
- va_list ap;
- va_start(ap, fmt);
- err_doit(1, errno, fmt, ap);
- va_end(ap);
- abort(); /* dump core and terminate */
- exit(1); /* shouldn't get here */
- }
- /*
- * Nonfatal error unrelated to a system call.
- * Print a message and return.
- */
- void err_msg(const char *fmt, ...)
- {
- va_list ap;
- va_start(ap, fmt);
- err_doit(0, 0, fmt, ap);
- va_end(ap);
- }
- /*
- * Fatal error unrelated to a system call.
- * Print a message and terminate.
- */
- void err_quit(const char *fmt, ...)
- {
- va_list ap;
- va_start(ap, fmt);
- err_doit(0, 0, fmt, ap);
- va_end(ap);
- exit(1);
- }
- /*
- * Print a message and return to caller.
- * Caller specifies "errnoflag".
- */
- static void err_doit(int errnoflag, int error, const char *fmt, va_list ap)
- {
- char buf[MAXLINE];
- vsnprintf(buf, MAXLINE, fmt, ap);
- if (errnoflag)
- snprintf(buf+strlen(buf), MAXLINE-strlen(buf), ": %s",
- strerror(error));
- strcat(buf, "\n");
- fflush(stdout); /* in case stdout and stderr are the same */
- fputs(buf, stderr);
- fflush(NULL); /* flushes all stdio output streams */
- }
6. 注销,重启
7. 代码文件
- #include "apue.h"
- #include "error.h"
Linux - Unix环境高级编程(第三版) 源代码编译(即头文件apue.h如何使用问题)【转】的更多相关文章
- Linux - Unix环境高级编程(第三版) 代码编译
Unix环境高级编程(第三版) 代码编译 本文地址:http://blog.csdn.net/caroline_wendy 时间:2014.10.2 1. 下载代码:http://www.apuebo ...
- 【转】apue《UNIX环境高级编程第三版》第一章答案详解
原文网址:http://blog.csdn.net/hubbybob1/article/details/40859835 大家好,从这周开始学习apue<UNIX环境高级编程第三版>,在此 ...
- Unix环境高级编程第三版中实例代码如何在自己的linux上运行的问题
学习Linux已经有2个月了,最近被期末考试把进度耽误了,前几天把Unix环境高级编程看了两章,感觉对Linux的整体有了一些思路,今天尝试着对第一章涉及到的一个简单的交互式shell编译运行一下,结 ...
- APUE(unix环境高级编程)第三版---first day---部署书中实例的运行环境(apue.h)
操作环境:RHEL7.0 部署apue.h实例运行环境 1.下载头文件src.3e.tar.gz 2.解压 tar zxvf src.3e.tar.gz 3.创建普通用户(我仿照书上创建的sar用户) ...
- 《UNIX环境高级编程第三版》apue.h等源码文件的编译安装
操作系统:Ubuntu 12/14 1.下载书中的源代码:点击下载 2.编译 tar -zxvf *.tar.gz cd ./apue.3e make 报错: can,t find -lbsd 解决办 ...
- 《UNIX环境高级编程(第3版)》
<UNIX环境高级编程(第3版)> 基本信息 原书名:Advanced Programming in the UNIX Environment (3rd Edition) (Addison ...
- unix环境高级编程第三章笔记
文件描述符 1.文件描述符的概念 对于内核而言,所有打开的文件都会用一个文件描述符来引用,打开或和创建一个新文件的时候,内核会给进程返回一个文件描述符,而当使用read write时,可以使用这个文件 ...
- UNIX环境高级编程-第三章习题
1,当读写磁盘文件时,read,write等函数确实是不带缓冲机制的吗?请说明原因. 答:所有磁盘I/O都要经过内核的块缓存区(即内核的缓冲区高速缓存).唯一例外的是对原始磁盘设备的I/O,但是我们不 ...
- 《UNIX环境高级编程 第2版》读书笔记
CH1-2:基础知识.标准化 1 文件和目录 文件名:不能含/(分隔路径)和null(终止路径),255字符. 目录处理:opendir() readdir() closedir() 更改工作目录:c ...
随机推荐
- 推荐一款基于 AI 开发的 IDE 插件,帮助提升编码效率
最近在浏览技术社区的时候,发现了一款神奇 IDE 插件,官网称可以利用 AI 帮助程序员写代码,一下子吸引了我的好奇心.赶紧下载下来使用一番,感觉确实蛮神奇,可以火速提升编程效率. 这款插件叫做 ai ...
- unity3d Resources.Load动态加载资源
初步整理并且学习unity3d资源加载方法,预计用时两天完成入门学习Unity3d常用两种加载资源方案:Resources.Load和AssetBundle Resources.Load就是从一个缺省 ...
- free如何知道释放内存长度:vs与glibc分配内存时编译器内部处理
鉴于网上这个资料实在太少,将以前整理过却未完全的一篇文章贴出来,希望大牛指正vs下内存管理方式.可联系gaoshiqiang1987@163.com vs分配内存 vs没有源码,编译器在分配内存时,分 ...
- 济南day1下午
下午 预:60+100+30 实:30+30+30 T1水题(water) T1写了二分图匹配 听说有70分,写挫了.... 正解:贪心,按长度排序, 对于第一幅牌里面的,在第二个里面,找一个长度小于 ...
- 转 Windows串口过滤驱动程序的开发
在Windows系统上与安全软件相关的驱动开发过程中,“过滤(filter)”是极其重要的一个概念.过滤是在不影响上层和下层接口的情况下,在Windows系统内核中加入新的层,从而不需要修改上层的软件 ...
- proc_get_status() has been disabled for security reasons
找到php.ini搜索proc_get_status去掉即可.
- Intent 传递对象
方法: 可以让这个要传递的对象所属类实现Serializable或者Parcelable接口, 然后利用onCreate函数中的Bundle参数作为载体,传递这个对象. 例如: <span st ...
- Go -- pprof协程监控
go中有pprof包来做代码的性能监控,在两个地方有包: net/http/pprof runtime/pprof 其实net/http/pprof中只是使用runtime/pprof包来进行封装了一 ...
- C#文件路径操作总结【转】
http://www.cnblogs.com/zhoufoxcn/archive/2006/10/24/2515874.html 一.获取当前文件的路径 1. System.Diagnostics ...
- Exchange 2013 Database Move to New Partition
建议不要删除默认数据库,可以通过修改默认数据库名称.路径等实现您的需求. 客戶:The HK Anti-Cancer Society. 要求:遷移數據庫(01)到新分區,實際是遷移成為數據庫(05) ...