UNIX网络编程 环境搭建

本文详细介绍如何配置UNIX网络编程所需的动态链接库或静态链接库,包括如何下载所需的头文件和示例源码,并提供了具体的编译步骤。此外,还介绍了如何将编译后的静态库和头文件放置在系统路径中以便随时调用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

配置好动态链接库或者静态链接库

1,下载UNIX网络编程书的头文件及示例源码unpv13e

2    按照readme来编译

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

3. 这个时候可以按照readme里提到的方法编译运行该源文件里的代码

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

    make daytimetcpcli

    ./daytimetcpcli 127.0.0.1

但是如果想在任何位置都可以编译unix网络编程的程序, 或者说使用unp.h头文件

4,将生成的libunp.a静态库复制到/usr/lib/和/usr/lib64/中。

[html]  view plain  copy
 print ?
  1. cd ..   //回到unpv12e目录  
[html]  view plain  copy
 print ?
  1. sudo cp libunp.a /usr/lib  
  2. sudo cp libunp.a /usr/lib64  


5,修改unp.h并将其和config.h拷贝到/usr/include中,为了以后include方便

[python]  view plain  copy
 print ?
  1. gedit lib/unp.h   //将unp.h中#include "../config.h"修改为#include "config.h"  
[python]  view plain  copy
 print ?
  1. sudo cp lib/unp.h /usr/include  
  2. sudo cp config.h /usr/include  






转载于:https://www.cnblogs.com/gremount/p/5803093.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值