Ubuntu中网络编程的环境配置

简介: Ubuntu中网络编程的环境配置

《UNP》中源代码的编译和使用 (2010-10-16 21:13)转载  

分类: 网络相关    

最近看了下《UNIX网络编程》,就想把里面的源代码搞过来运行下。以前也搞过,不过老是忘记使用代码的步骤了,所以就记录下,防止每次还要弄半天。


 

从网上下载压缩包解压到自己设定的目录下面,我的是/home/**/myprogram/UNP/unpv13e/,里面有  

./    
├── aclocal.m4    
├── advio    
├── bcast    
├── config.guess    
├── config.h    
├── config.h.in    
├── config.log    
├── config.status    
├── config.sub    
├── configure    
├── configure.in    
├── debug    
├── DISCLAIMER    
├── icmpd    
├── inetd    
├── install-sh    
├── intro    
├── ioctl    
├── ipopts    
├── key    
├── lib    
├── libfree    
├── libgai    
├── libroute    
├── libunp.a(就是为了生成这个文件)    
├── Make.defines    
├── Make.defines.in    
├── Makefile    
├── Makefile.in    
├── mcast    
├── mysdr    
├── names    
├── nonblock    
├── oob    
├── ping    
├── README    
├── route    
├── rtt    
├── sctp    
├── select    
├── server    
├── sigio    
├── sock    
├── sockopt    
├── sparc64-unknown-freebsd5.1    
├── ssntp    
├── streams    
├── tcpcliserv    
├── test    
├── threads    
├── traceroute    
├── udpcksum    
├── udpcliserv    
├── unixdomain    
├── unpv13e    
└── VERSION

这么多的东西,呵呵!!,当然我们不能忘记了README这个助手  

QUICK AND DIRTY    

===============

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
If all that works, you  

其实需要执行的就是前三步,其实就是为了生成libunp.a。复制这个静态库到/usr/lib/和/usr/lib64/中,因为后来编译程序的话需要用到这个静态库。还得在环境变量中将这两个路径加上。


 

接下来的是头文件unp.h的问题,这个文件在这个解压缩目录的lib文件夹中。


 

因为里面所有的文件都包含了#include“unp.h”这一句话,为了方便可以有两种方法:  

一:    

1.将lib下面的unp.h复制到/usr/include文件夹下面,并保证环境变量中有/usr/include;    

2. 因为unp.h中有#include "../config.h",所以得把解压缩目录下面的config.h复制到/usr/include中,并将unp.h中的#include "../config.h"改成 #include "config.h"。    

3在unp.h中添加一行:    

#define MAX_LINE 2048


 

二:  

1.将Lib文件夹下面的unp.h移到unpv13e中,    

2.参照上面的第二条;    

3.参照上面的第三条;    

4.以后在子文件夹里面编译程序,把#include"unp.h"改为#include"../unp.h"


 

做完上面,我们就可以编译单个程序了,比如intro/byteorder.c。

root@**-desktop:/home/**/myprogram/UNP/unpv13e/intro# gcc -W -o byteorder byteorder.c -lunp  
root@**-desktop:/home/**/myprogram/UNP/unpv13e/intro# ./byteorder    
i686-pc-linux-gnu: little-endian
相关文章
|
8天前
|
Ubuntu Windows
【Ubuntu/Arm】Ubuntu 系统如何链接有线网络(非虚拟机)?
【Ubuntu/Arm】Ubuntu 系统如何链接有线网络(非虚拟机)?
|
8天前
|
Ubuntu
虚拟机Ubuntu连接不了网络的解决方法
虚拟机Ubuntu连接不了网络的解决方法
|
8天前
|
Ubuntu
如何在 Ubuntu 中创建网络绑定和桥接?
如何在 Ubuntu 中创建网络绑定和桥接?
100 0
如何在 Ubuntu 中创建网络绑定和桥接?
|
7月前
|
分布式计算 Ubuntu Hadoop
【Linux】在ubuntu18.04系统中配置网络信息(超有用,完美解决,只看这一篇就行了)
【Linux】在ubuntu18.04系统中配置网络信息(超有用,完美解决,只看这一篇就行了)
291 0
|
8天前
|
Ubuntu 网络协议 Linux
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
52 0
|
8天前
|
Ubuntu 网络协议
百度搜索:蓝易云【Ubuntu网络配置教程】
现在,你已经成功在Ubuntu上配置了网络接口。根据你的需求,网络接口将使用静态IP地址或DHCP自动获取IP地址。
44 1
|
8天前
|
Web App开发 Ubuntu C++
docker Ubuntu wasm 环境配置 浏览器debug c/c++
docker Ubuntu wasm 环境配置 浏览器debug c/c++
47 0
|
9月前
|
关系型数据库 MySQL 数据安全/隐私保护
Ubuntu18.04.6 通过自编译的方式指定mysql5.7安装目录(有网络)
Ubuntu18.04.6 通过自编译的方式指定mysql5.7安装目录(有网络)
77 0
|
9月前
|
存储 Ubuntu 开发工具
Ubuntu网络设置之固定IP详解
尊敬的家人们,欢迎观看我的文章!今天,我们将为您介绍Ubuntu22.04操作系统中固定IP的设置方法,帮助您更好地管理网络连接并提高网络稳定性。
346 0
Ubuntu网络设置之固定IP详解
|
5月前
|
缓存 并行计算 Ubuntu
科研GPU环境配置-快让师兄弟们优雅地享受共享环境吧!
以下列举我对实验室4090的操作,目的是为了让实验室所有人都有隔离的沙盒环境,节省硬盘以及更方便 一听说老师买了24G 4090,真的超级兴奋!!!
114 0
科研GPU环境配置-快让师兄弟们优雅地享受共享环境吧!