周六收到这本书,周末在看这本书,但是下载下来源代码后,不知道如何运行,参考了该书主页中所说的make方法,还是不行.
源代码主页链接:http://man7.org/tlpi/code/BUI...
源代码下载链接:http://man7.org/tlpi/code/ind...
源代码有两个版本,Distribution version Book version
参考作者主页http://www.man7.org/tlpi/code...,中的操作步骤,下载代码,直接make,报一堆错误.
附上错误详细信息与图片:
[root@host tlpi-dist]# make
make[1]: Entering directory `/root/tlpi-dist/lib'
sh Build_ename.sh > ename.c.inc
echo 1>&2 "ename.c.inc built"
ename.c.inc built
cc -c -g -std=c99 -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -g -I../lib -pedantic -Wall -W -Wmissing-prototypes -Wno-sign-compare -Wno-unused-parameter *.c
become_daemon.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../daemons/become_daemon.c
^
binary_sems.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../svsem/binary_sems.c
^
create_pid_file.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../filelock/create_pid_file.c
^
curr_time.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../time/curr_time.c
^
event_flags.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../svsem/event_flags.c
^
file_perms.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../files/file_perms.c
^
inet_sockets.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../sockets/inet_sockets.c
^
itimerspec_from_str.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../timers/itimerspec_from_str.c
^
print_rlimit.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../procres/print_rlimit.c
^
print_rusage.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../procres/print_rusage.c
^
print_wait_status.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../procexec/print_wait_status.c
^
pty_fork.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../pty/pty_fork.c
^
pty_master_open.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../pty/pty_master_open.c
^
rdwrn.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../sockets/rdwrn.c
^
read_line_buf.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../sockets/read_line_buf.c
^
read_line.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../sockets/read_line.c
^
region_locking.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../filelock/region_locking.c
^
signal.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../signals/signal.c
^
signal_functions.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../signals/signal_functions.c
^
tty_functions.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../tty/tty_functions.c
^
ugid_functions.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../users_groups/ugid_functions.c
^
unix_sockets.c:1:1: error: expected identifier or ‘(’ before ‘.’ token
../sockets/unix_sockets.c
^
make[1]: *** [../libtlpi.a] Error 1
make[1]: Leaving directory `/root/tlpi-dist/lib'
make[1]: Entering directory `/root/tlpi-dist/acl'
make[1]: *** No rule to make target `../libtlpi.a', needed by `acl_update'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/acl'
make[1]: Entering directory `/root/tlpi-dist/altio'
make[1]: *** No rule to make target `../libtlpi.a', needed by `demo_sigio'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/altio'
make[1]: Entering directory `/root/tlpi-dist/cap'
make[1]: *** No rule to make target `../libtlpi.a', needed by `check_password_caps'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/cap'
make[1]: Entering directory `/root/tlpi-dist/daemons'
make[1]: *** No rule to make target `../libtlpi.a', needed by `daemon_SIGHUP'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/daemons'
make[1]: Entering directory `/root/tlpi-dist/dirs_links'
make[1]: *** No rule to make target `../libtlpi.a', needed by `bad_symlink'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/dirs_links'
make[1]: Entering directory `/root/tlpi-dist/filebuff'
make[1]: *** No rule to make target `../libtlpi.a', needed by `copy'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/filebuff'
make[1]: Entering directory `/root/tlpi-dist/fileio'
make[1]: *** No rule to make target `../libtlpi.a', needed by `atomic_append'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/fileio'
make[1]: Entering directory `/root/tlpi-dist/filelock'
make[1]: *** No rule to make target `../libtlpi.a', needed by `i_fcntl_locking'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/filelock'
make[1]: Entering directory `/root/tlpi-dist/files'
make[1]: *** No rule to make target `../libtlpi.a', needed by `t_chown'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/files'
make[1]: Entering directory `/root/tlpi-dist/filesys'
make[1]: *** No rule to make target `../libtlpi.a', needed by `t_statvfs'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/filesys'
make[1]: Entering directory `/root/tlpi-dist/getopt'
make[1]: *** No rule to make target `../libtlpi.a', needed by `t_getopt'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/getopt'
make[1]: Entering directory `/root/tlpi-dist/inotify'
make[1]: *** No rule to make target `../libtlpi.a', needed by `demo_inotify'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/inotify'
make[1]: Entering directory `/root/tlpi-dist/loginacct'
make[1]: *** No rule to make target `../libtlpi.a', needed by `dump_utmpx'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/loginacct'
make[1]: Entering directory `/root/tlpi-dist/memalloc'
make[1]: *** No rule to make target `../libtlpi.a', needed by `free_and_sbrk'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/memalloc'
make[1]: Entering directory `/root/tlpi-dist/mmap'
make[1]: *** No rule to make target `../libtlpi.a', needed by `anon_mmap'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/mmap'
make[1]: Entering directory `/root/tlpi-dist/pgsjc'
make[1]: *** No rule to make target `../libtlpi.a', needed by `catch_SIGHUP'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/pgsjc'
make[1]: Entering directory `/root/tlpi-dist/pipes'
make[1]: *** No rule to make target `../libtlpi.a', needed by `change_case'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/pipes'
make[1]: Entering directory `/root/tlpi-dist/pmsg'
make[1]: *** No rule to make target `../libtlpi.a', needed by `mq_notify_sig'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/pmsg'
make[1]: Entering directory `/root/tlpi-dist/proc'
make[1]: *** No rule to make target `../libtlpi.a', needed by `bad_longjmp'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/proc'
make[1]: Entering directory `/root/tlpi-dist/proccred'
make[1]: *** No rule to make target `../libtlpi.a', needed by `idshow'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/proccred'
make[1]: Entering directory `/root/tlpi-dist/procexec'
make[1]: *** No rule to make target `../libtlpi.a', needed by `acct_on'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/procexec'
make[1]: Entering directory `/root/tlpi-dist/procpri'
make[1]: *** No rule to make target `../libtlpi.a', needed by `sched_set'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/procpri'
make[1]: Entering directory `/root/tlpi-dist/procres'
make[1]: *** No rule to make target `../libtlpi.a', needed by `rusage'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/procres'
make[1]: Entering directory `/root/tlpi-dist/progconc'
make[1]: *** No rule to make target `../libtlpi.a', needed by `syscall_speed'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/progconc'
make[1]: Entering directory `/root/tlpi-dist/psem'
make[1]: *** No rule to make target `../libtlpi.a', needed by `psem_getvalue'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/psem'
make[1]: Entering directory `/root/tlpi-dist/pshm'
make[1]: *** No rule to make target `../libtlpi.a', needed by `pshm_create'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/pshm'
make[1]: Entering directory `/root/tlpi-dist/pty'
make[1]: *** No rule to make target `../libtlpi.a', needed by `script'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/pty'
make[1]: Entering directory `/root/tlpi-dist/shlibs'
cc -std=c99 -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -g -I../lib -pedantic -Wall -W -Wmissing-prototypes -Wno-sign-compare -Wno-unused-parameter -c -o dynload.o dynload.c
make[1]: *** No rule to make target `../libtlpi.a', needed by `dynload'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/shlibs'
make[1]: Entering directory `/root/tlpi-dist/signals'
make[1]: *** No rule to make target `../libtlpi.a', needed by `catch_rtsigs'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/signals'
make[1]: Entering directory `/root/tlpi-dist/sockets'
cc -std=c99 -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -g -I../lib -pedantic -Wall -W -Wmissing-prototypes -Wno-sign-compare -Wno-unused-parameter -c -o i6d_ucase_sv.o i6d_ucase_sv.c
make[1]: *** No rule to make target `../libtlpi.a', needed by `i6d_ucase_sv'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/sockets'
make[1]: Entering directory `/root/tlpi-dist/svipc'
make[1]: *** No rule to make target `../libtlpi.a', needed by `svmsg_demo_server'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/svipc'
make[1]: Entering directory `/root/tlpi-dist/svmsg'
make[1]: *** No rule to make target `../libtlpi.a', needed by `svmsg_chqbytes'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/svmsg'
make[1]: Entering directory `/root/tlpi-dist/svsem'
make[1]: *** No rule to make target `../libtlpi.a', needed by `svsem_create'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/svsem'
make[1]: Entering directory `/root/tlpi-dist/svshm'
make[1]: *** No rule to make target `../libtlpi.a', needed by `svshm_attach'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/svshm'
make[1]: Entering directory `/root/tlpi-dist/sysinfo'
make[1]: *** No rule to make target `../libtlpi.a', needed by `t_uname'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/sysinfo'
make[1]: Entering directory `/root/tlpi-dist/syslim'
make[1]: *** No rule to make target `../libtlpi.a', needed by `t_fpathconf'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/syslim'
make[1]: Entering directory `/root/tlpi-dist/threads'
make[1]: *** No rule to make target `../libtlpi.a', needed by `detached_attrib'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/threads'
make[1]: Entering directory `/root/tlpi-dist/time'
make[1]: *** No rule to make target `../libtlpi.a', needed by `calendar_time'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/time'
make[1]: Entering directory `/root/tlpi-dist/timers'
make[1]: *** No rule to make target `../libtlpi.a', needed by `ptmr_null_evp'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/timers'
make[1]: Entering directory `/root/tlpi-dist/tty'
make[1]: *** No rule to make target `../libtlpi.a', needed by `demo_SIGWINCH'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/tty'
make[1]: Entering directory `/root/tlpi-dist/users_groups'
make[1]: *** No rule to make target `../libtlpi.a', needed by `t_getpwent'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/users_groups'
make[1]: Entering directory `/root/tlpi-dist/vmem'
make[1]: *** No rule to make target `../libtlpi.a', needed by `memlock'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/vmem'
make[1]: Entering directory `/root/tlpi-dist/xattr'
make[1]: *** No rule to make target `../libtlpi.a', needed by `t_setxattr'. Stop.
make[1]: Leaving directory `/root/tlpi-dist/xattr'
make: *** [all] Error 2
有没有读过,或者正在读该书的朋友,麻烦您指点下.
我看makefile的话是构造一些编译规则,比如先编译谁再编译谁,如果不用makefile,同样我也可以把某一个.c文件所需要的头文件拷贝到同一个目录,然后gcc多文件编译吧?
另外segmentfault,在新建该提问时无法提交编辑,只能随便写点东西然后发布的内容,因此有了一个踩,不知道是什么原因,导致不能发布该提问.
不知道你遇到了什么问题。
我下载 Distribution version 的代码,然后解压后进去直接运行 make 即可正常编译,gcc 版本是 7.2.0。