工学1号馆

home

UNIX网络编程卷1源码编译问题

By Wu Yudong on August 04, 2016

直接按照书中的代码,编译的时候出现一堆问题,提示的错误都是文件找不到,其实在源代码包中的README文件中,详细的记录着编译的步骤

本文地址:http://wuyudong.com/2016/08/04/2437.html,转载请注明源地址。

我的编译环境:Ubuntu 14.04.2 LTS 64bit

Execute the following from the src/ directory:

    ./configure    # try to figure out all implementation differences

    cd lib         # build the basic library that all programs need
    make           # use "gmake" everywhere on BSD/OS systems

    cd ../libfree  # continue building the basic library
    make

    cd ../libroute # only if your system supports 4.4BSD style routing sockets
    make           # only if your system supports 4.4BSD style routing sockets

    cd ../libxti   # only if your system supports XTI
    make           # only if your system supports XTI

    cd ../intro    # build and test a basic client program
    make daytimetcpcli
    ./daytimetcpcli 127.0.0.1

按照操作一路搞下来,最后运行:wu@ubuntu:~/opt/unpv13e/intro$ ./daytimetcpcli 127.0.0.1
得到错误提示:connect error: Connection refused
原因:系统默认没打开daytime服务。
解决办法:
在intro中执行一下命令打开daytime服务

wu@ubuntu:~/opt/unpv13e/intro$ make daytimetcpsrv
gcc -I../lib -g -O2 -D_REENTRANT -Wall   -c -o daytimetcpsrv.o daytimetcpsrv.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpsrv daytimetcpsrv.o ../libunp.a -lpthread
wu@ubuntu:~/opt/unpv13e/intro$ sudo ./daytimetcpsrv

开启服务后,打开另一个终端

wu@ubuntu:~/opt/unpv13e/intro$ ./daytimetcpcli 127.0.0.1
Thu Aug  4 04:16:52 2016

搞定

如果文章对您有帮助,欢迎点击下方按钮打赏作者

Comments

No comments yet.
To verify that you are human, please fill in "七"(required)