zoukankan      html  css  js  c++  java
  • apue源代码的使用与编译

    原文网址:http://ordinarysky.cn/?p=492

    编译源代码

    1、从官网下载源代码www.apuebook.com

    2、解压

    3、默认解压后的源代码名称为:apue.2e,里面包含了所有的代码

    4、修改目录,我的系统是ubuntu10.10,修改apue.2e下的Make.defines.linux
            WKDIR=/home/sdoning/apue/apue.2e(主要是该路径)

    5、在apue.2e目录下运行make命令

    6、错误与解决

    gcc -DLINUX -ansi -I/home/sdoning/apue/apue.2e/include -Wall -D_GNU_SOURCE   -c -o getenv1.o getenv1.c
    getenv1.c:4: error: ‘ARG_MAX’ undeclared here (not in a function)
    make[2]: *** [getenv1.o] Error 1
    make[2]: Leaving directory `/home/sdoning/apue/apue.2e/threadctl’
    make[1]: *** [linux] Error 1
    make[1]: Leaving directory `/home/sdoning/apue/apue.2e’
    make: *** [all] Error 2

    解决方法:

    在apue.2e/include/apue.h中添加一行:
    #define ARG_MAX 4096
    打开apue.2e/threadctl/getenv3.c(包括getenv1.c),添加一行:
    #include "apue.h"

    7、再次编译即可。

    使用源代码:

    1、知道源代码的软连接与位置
    sdoning@ubuntu:~/apue/apue.2e$ ll fig1.3
    lrwxrwxrwx 1 sdoning sdoning 10 2010-11-27 07:27 fig1.3 -> file/ls1.c

    2、进入file目录

    sdoning@ubuntu:~/apue/apue.2e/file$ ls
    access       devrdev.c    ftw4.c    longpath.c  seek.c       umask.c
    access.c     fileflags    hello     ls1         solaris.mk   unlink
    cdpwd        fileflags.c  hello.c   ls1.c       testerror    unlink.c
    cdpwd.c      filetype     hole      macos.mk    testerror.c  zap
    changemod    filetype.c   hole.c    mycd        uidgid       zap.c
    changemod.c  freebsd.mk   linux.mk  mycd.c      uidgid.c
    devrdev      ftw4         longpath  seek        umask

    3、运行

    sdoning@ubuntu:~/apue/apue.2e/file$ ./ls1 /home
    ..
    sdoning
    .

  • 相关阅读:
    深入类的方法
    泛型集合
    深入C#数据类型
    深入.net框架
    错题
    详解Python Graphql
    深入理解分布式调度框架TBSchedule及源码分析
    30分钟闲置服务器建站(gitlab为例)
    Webpack开发指南
    mybatis-generator
  • 原文地址:https://www.cnblogs.com/wangshuo/p/2010512.html
Copyright © 2011-2022 走看看