二,从源代码开始编译安装iperf3

news2024/9/27 17:34:55

本文目录

  • Linux系统中编译安装基本知识简介
  • 第一步,执行configure
  • 第二步,执行make
  • 第三步,make install
  • 其它功能说明

Linux系统中编译安装基本知识简介

从前一文章"一,下载iPerf3最新源代码"我们已经知道如何通过git的方式将代码下载(clone)到本地,本文将在这个基础上讲一下如何从源代码开始配置,编译与安装iperf3。

正如我们所知道的,通常Linux系统里,从源代码的方式得到一个可用的能在系统里直接执行的程序,通常需要分成三步走:configure(配置)、make(编译)和make install(安装)。

  • configure是个shell脚本
    用来检测安装平台的目标特征,然后生成对应的Makefile,以及生成系统相关的编译选项(比如是不是支持cpu_affinity等等)宏。执行configure通常不需要带配置参数,当然有需要时也可以带的,具体可以通过 ./configure --help 察看详细的说明。
  • make
    make 是Linux 里的一个编译用的程序,通过Makefile 里面定义的规则自动化的调用 gcc 、ld 以及运行某些需要的程序对目标源代码进行编译。
  • make install
    将上一步编译生成的程序安装到系统里,通常默认安装到是/usr/local/bin/目录下

iperf3的编译与安装也是这三个步骤,接下来一起来看一下这三步,iperf3在系统里是怎么变化的

第一步,执行configure

进入源代码目录/home/xxx/iperf3/iperf目录后,我们直接输入./configure命令,则可以看到开始一步步检查当前系统的目标特征,生成makefile和相应的编译选项。

xxx@xxx-pc:~/iperf3$ cd iperf/
xxx@xxx-pc:~/iperf3/iperf$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... (cached) gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to enable C11 features... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for ranlib... (cached) ranlib
checking whether ln -s works... yes
checking for library containing floor... -lm
checking for library containing socket... none required
checking for library containing inet_ntop... none required
checking for an ANSI C-conforming const... yes
checking for poll.h... yes
checking for linux/tcp.h... yes
checking for sys/socket.h... yes
checking for netinet/sctp.h... no
checking for endian.h... yes
checking for pkg-config... pkg-config
checking for openssl/ssl.h in /usr/local/ssl... no
checking for openssl/ssl.h in /usr/lib/ssl... no
checking for openssl/ssl.h in /usr/ssl... no
checking for openssl/ssl.h in /usr/pkg... no
checking for openssl/ssl.h in /usr/local... no
checking for openssl/ssl.h in /usr... no
checking whether compiling and linking against OpenSSL works... no
checking TCP_CONGESTION socket option... yes
checking TCP_USER_TIMEOUT socket option... yes
checking IPv6 flowlabel support... yes
checking for cpuset_setaffinity... no
checking for sched_setaffinity... yes
checking for SetProcessAffinityMask... no
checking for daemon... yes
checking for sendfile... yes
checking for getline... yes
checking SO_MAX_PACING_RATE socket option... yes
checking SO_BINDTODEVICE socket option... yes
checking IP_MTU_DISCOVER socket option... yes
checking IP_DONTFRAG socket option... no
checking IP_DONTFRAGMENT socket option... no
checking any kind of DF socket option... yes
checking for struct tcp_info.tcpi_snd_wnd... yes
checking for library containing clock_gettime... none required
checking for clock_gettime... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/version.h
config.status: creating examples/Makefile
config.status: creating iperf3.spec
config.status: creating src/iperf_config.h
config.status: executing depfiles commands
config.status: executing libtool commands

最后我们可以看到,configure完成后,生成了如下新文件,主要有makefile文件和根据当前系统特性生成的iperf_config.h里定义的各种编译宏选项。
在这里插入图片描述

第二步,执行make

同上一步,在进入源代码目录/home/xxx/iperf3/iperf目录后,运行make命令后,我们可以看到系统不停的打印出编译过程中的各种过程与结果,到最后完成编译过程。

xxx@xxx-pc:~/iperf3/iperf$ make
Making all in src
make[1]: 进入目录“/home/xxx/iperf3/iperf/src”
make  all-am
make[2]: 进入目录“/home/xxx/iperf3/iperf/src”
  CC       iperf3-main.o
  CC       cjson.lo
  CC       iperf_api.lo
  CC       iperf_error.lo
  CC       iperf_auth.lo
  CC       iperf_client_api.lo
  CC       iperf_locale.lo
  CC       iperf_server_api.lo
  CC       iperf_tcp.lo
  CC       iperf_udp.lo
  CC       iperf_sctp.lo
  CC       iperf_util.lo
  CC       iperf_time.lo
  CC       dscp.lo
  CC       net.lo
  CC       tcp_info.lo
  CC       timer.lo
  CC       units.lo
  CCLD     libiperf.la
  CCLD     iperf3
  CC       t_timer-t_timer.o
  CCLD     t_timer
  CC       t_units-t_units.o
  CCLD     t_units
  CC       t_uuid-t_uuid.o
  CCLD     t_uuid
  CC       t_api-t_api.o
  CCLD     t_api
  CC       t_auth-t_auth.o
  CCLD     t_auth
make[2]: 离开目录“/home/xxx/iperf3/iperf/src”
make[1]: 离开目录“/home/xxx/iperf3/iperf/src”
Making all in examples
make[1]: 进入目录“/home/xxx/iperf3/iperf/examples”
  CC       mic-mic.o
  CCLD     mic
  CC       mis-mis.o
  CCLD     mis
make[1]: 离开目录“/home/xxx/iperf3/iperf/examples”
make[1]: 进入目录“/home/xxx/iperf3/iperf”
make[1]: 对“all-am”无需做任何事。
make[1]: 离开目录“/home/xxx/iperf3/iperf”

然后我们可以看到,编译完成的结果,除了在src目录下生成各种.o文件和.lo文件外,最终生在一个带x可执行属性的iperf3文件。

xxx@xxx-pc:~/iperf3/iperf/src$ ls -l | grep iperf3
-rwxrwxr-x 1 xxx xxx   6247  225 08:43 iperf3
-rw-rw-r-- 1 xxx xxx  19486  224 20:32 iperf3.1
-rw-rw-r-- 1 xxx xxx  40552  225 08:43 iperf3-main.o

第三步,make install

在第二步,我们已经通过make生成了目标可执行程序和对应的一堆可执行程序要依赖的库文件,接下来,我们就要把程序安装到系统里(将目标程序,帮忙文件,使用手册,所有的配置文件和依赖的库文件拷贝到linux系统对应的目录下)。

xxx@xxx-pc:~/iperf3/iperf$ sudo make install
Making install in src
make[1]: 进入目录“/home/xxx/iperf3/iperf/src”
make[2]: 进入目录“/home/xxx/iperf3/iperf/src”
 /usr/bin/mkdir -p '/usr/local/lib'
 /bin/bash ../libtool   --mode=install /usr/bin/install -c   libiperf.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libiperf.so.0.0.0 /usr/local/lib/libiperf.so.0.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libiperf.so.0.0.0 libiperf.so.0 || { rm -f libiperf.so.0 && ln -s libiperf.so.0.0.0 libiperf.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libiperf.so.0.0.0 libiperf.so || { rm -f libiperf.so && ln -s libiperf.so.0.0.0 libiperf.so; }; })
libtool: install: /usr/bin/install -c .libs/libiperf.lai /usr/local/lib/libiperf.la
libtool: install: /usr/bin/install -c .libs/libiperf.a /usr/local/lib/libiperf.a
libtool: install: chmod 644 /usr/local/lib/libiperf.a
libtool: install: ranlib /usr/local/lib/libiperf.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /usr/bin/mkdir -p '/usr/local/bin'
  /bin/bash ../libtool   --mode=install /usr/bin/install -c iperf3 '/usr/local/bin'
libtool: install: /usr/bin/install -c .libs/iperf3 /usr/local/bin/iperf3
 /usr/bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 iperf_api.h '/usr/local/include'
 /usr/bin/mkdir -p '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 iperf3.1 '/usr/local/share/man/man1'
 /usr/bin/mkdir -p '/usr/local/share/man/man3'
 /usr/bin/install -c -m 644 libiperf.3 '/usr/local/share/man/man3'
make[2]: 离开目录“/home/xxx/iperf3/iperf/src”
make[1]: 离开目录“/home/xxx/iperf3/iperf/src”
Making install in examples
make[1]: 进入目录“/home/xxx/iperf3/iperf/examples”
make[2]: 进入目录“/home/xxx/iperf3/iperf/examples”
make[2]: 对“install-exec-am”无需做任何事。
make[2]: 对“install-data-am”无需做任何事。
make[2]: 离开目录“/home/xxx/iperf3/iperf/examples”
make[1]: 离开目录“/home/xxx/iperf3/iperf/examples”
make[1]: 进入目录“/home/xxx/iperf3/iperf”
make[2]: 进入目录“/home/xxx/iperf3/iperf”
make[2]: 对“install-exec-am”无需做任何事。
make[2]: 对“install-data-am”无需做任何事。
make[2]: 离开目录“/home/xxx/iperf3/iperf”
make[1]: 离开目录“/home/xxx/iperf3/iperf”

完成安装后,我们可以通过以下命令查看iperf3被安装到了/usr/local/bin目录下,我们执行iperf3 -v可以看到iperf 3.9版本已经被成功安装并可以执行使用了。

wangsheng@wangsheng-pc:~/iperf3/iperf$ whereis iperf3
iperf3: /usr/local/bin/iperf3
wangsheng@wangsheng-pc:~/iperf3/iperf$ iperf3 -v
iperf 3.9 (cJSON 1.7.13)
Linux wangsheng-pc 5.15.0-58-generic #64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023 x86_64
Optional features available: CPU affinity setting, IPv6 flow label, SCTP, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing, authentication

其它功能说明

卸载iperf3,运行sudo make uninstall后,我们可以通过whereis iperf3看到iperf3已经被从系统里移除。

xxx@xxx-pc:~/iperf3/iperf$ sudo make uninstall
Making uninstall in src
make[1]: 进入目录“/home/xxx/iperf3/iperf/src”
 ( cd '/usr/local/bin' && rm -f iperf3 )
 ( cd '/usr/local/include' && rm -f iperf_api.h )
 /bin/bash ../libtool   --mode=uninstall rm -f '/usr/local/lib/libiperf.la'
libtool: uninstall: rm -f /usr/local/lib/libiperf.la /usr/local/lib/libiperf.so.0.0.0 /usr/local/lib/libiperf.so.0 /usr/local/lib/libiperf.so /usr/local/lib/libiperf.a
 ( cd '/usr/local/share/man/man1' && rm -f iperf3.1 )
 ( cd '/usr/local/share/man/man3' && rm -f libiperf.3 )
make[1]: 离开目录“/home/xxx/iperf3/iperf/src”
Making uninstall in examples
make[1]: 进入目录“/home/xxx/iperf3/iperf/examples”
make[1]: 对“uninstall”无需做任何事。
make[1]: 离开目录“/home/xxx/iperf3/iperf/examples”
make[1]: 进入目录“/home/xxx/iperf3/iperf”
make[1]: 对“uninstall-am”无需做任何事。
make[1]: 离开目录“/home/xxx/iperf3/iperf”
xxx@xxx-pc:~/iperf3/iperf$ whereis iperf3
iperf3:
xxx@xxx-pc:~/iperf3/iperf$ 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/371614.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Linux系统下命令行安装MySQL5.6+详细步骤

1、因为想在腾讯云的服务器上创建自己的数据库,所以我在这里是通过使用Xshell 7来连接腾讯云的远程服务器; 2、Xshell 7与服务器连接好之后,就可以开始进行数据库的安装了(如果服务器曾经安装过数据库,得将之前安装的…

干货 | 八条“黄金规则”解决RF电路寄生信号

PART 01 接地通孔应位于接地参考层开关处流经所布线路的所有电流都有相等的回流。耦合策略固然很多,不过回流通常流经相邻的接地层或与信号线路并行布置的接地。在参考层继续时,所有耦合都仅限于传输线路,一切都非常正常。不过,如…

MySQL关于NULL值,常见的几个坑

数据库版本MySQL8。 1.count 函数 觉得 NULL值 不算数 ,所以开发中要避免count的时候丢失数据。 如图所示,以下有7条记录,但是count(name)却只有6条。 为什么丢失数据?因为MySQL的count函数觉得 Null值不算数,就是说…

Shader(着色)

1.深度测试(Z-Buffer )每个像素需要一个深度来排序是否需要渲染,所以需要额外的buffer来存储,frame buffer 存颜色,depth buffer (z-buffer) 存深度。2.Lambert(漫反射)3.Blinn-Phong (高光)4.环…

Netty权威指南总结(一)

一、为什么选择Netty:API使用简单,开发门槛低,屏蔽了NIO通信的底层细节。功能强大,预制了很多种编解码功能,支持主流协议。定制能力强,可以通过ChannelHandler对通信框架进行灵活地拓展。性能高、成熟、稳定…

一文搞定Android Vsync原理简析

屏幕渲染原理"现代计算机之父"冯诺依曼提出了计算机的体系结构: 计算机由运算器,存储器,控制器,输入设备和输出设备构成,每部分各司其职,它们之间通过控制信号进行交互。计算机发展到现在,已经出…

【Python知识点桂电版】01基本数据类型

一、变量变量定义注:查看变量类型->type(变量)查看变量地址->id(变量)变量命名规则只允许出现:英文、中文、数字、下划线(不推荐用中文,不能以数字开头)大小写敏感不可使用关键字(如and)和…

代码随想录【Day24】| 开始回溯!77. 组合

回溯的本质是穷举,穷举所有可能,然后选出我们想要的答案,如果想让回溯法高效一些,可以加一些剪枝的操作,但也改不了回溯法就是穷举的本质。 那么既然回溯法并不高效为什么还要用它呢? 因为没得选&#xf…

cesium: 设置skybox透明并添加背景图 ( 003 )

第003个 点击查看专栏目录 本示例的目的是介绍如何在vue+cesium中设置skybox透明并添加背景图。 我们不想要黑乎乎的背景,想自定义一个背景图,然后前面显示地球。 直接复制下面的 vue+cesium源代码,操作2分钟即可运行实现效果. 文章目录 示例效果配置方式示例源代码(共70…

奇妙的background-clip:text

我们在学习CSS3时,一个背景属性background-clip用来对背景进行裁剪,即指定背景绘制的区域,通常我们使用的几个属性如下:值说明border-box默认值。背景绘制在边框方框内(剪切成边框方框)。padding-box背景绘…

【C++入门(上篇)】C++入门学习

前言: 在之前的学习中,我们已经对初阶数据结构进行相应了学习,加上之前C语言的学习功底。今天,我们将会踏上更高一级“台阶”的学习-----即C的学习!!! 文章目录1.C 简介1.1什么是C1.2.C的发展史…

【数据库】join SQL语句原理优化

背景 在实际的开发中,业务相关表都是通过uid或者一个可以标记业务领域的一个属性转换成的字段进行关联的,但是对于一些后续的业务,比如数据分析、下游系统使用、金融对账等业务,需要进行多表联查,之前实际生产的时候就…

【安卓开发】内容提供器

内容提供器实现了不同程序之间实现数据共享的功能。 7.2 运行时权限 安卓6.0版本后引入了运行时权限 每个权限都属于一个组&#xff0c;授权了其中一个&#xff0c;一个组内的权限都将会被授权。 测试代码 // AndroidManifest.xml中加入以下代码 <uses-permission andr…

魔改hustoj源码使其支持显示队名和队员及女队标志

0. 起因&需求 本文涉及到的开源项目Github地址&#xff1a;https://github.com/zhblue/hustoj 事件的起因是&#xff0c;计算机学院要举办一个院级的ACM比赛&#xff0c;然后捏… 老师给我提了一个需求&#xff0c;就是能不能把比赛排行榜显示的队名下标注对应的队员&…

光栅化Triangles(笔记)

field of view (可见区域) 该角度越大,需要透视投影的角度越大,成像显示的内容越多 有Y值,则可得出成像范围 屏幕: 典型的光栅处理设备所有像素都被表示为x,y坐标轴形式 3D方块成像步骤: 先将其所在平面化为 与屏幕等长等宽的形式: 如何将一个三角形拆成像素&#xff1f;采样…

C++学习笔记-2

C学习笔记-2输入/输出控制----I/O流命名空间的定义及使用string类型函数改进域解析符::扩大全局变量的作用域形式参数可带有默认值函数重载引用的定义与应用引用的概念及使用引用作为形式参数引用与指针的比较引用作为返回值动态内存空间用new申请动态内存空间用delete释放动态…

unicloud的aggregate聚合查询时间戳转日期

我特么不知道看了这个帖子几百遍才看明白到-----》unicloud数据库中&#xff0c;聚合操作如何操作时间戳&#xff1f; - DCloud问答 自己淋过雨老想着为别人撑伞&#xff0c;可怜我这35岁的老人家&#xff0c;给我去点关注&#xff01;&#xff01;&#xff01;&#xff01;&a…

centos上cliskhouse的安装记录

clickhouse是由俄罗斯Yandex公司开发的列式存储数据库&#xff0c;于2016年开源&#xff0c;clickhouse的定位是快速的数据分析&#xff0c;对于处理海量数据的情况性能非常好&#xff0c;在网上也有很多测试的案例&#xff0c;在大数据的情况下性能远超过其他数据库&#xff0…

ThreadLocal原理、结构、源码解析

文章目录一、Thread简介1.什么是ThreadLocal2.为什么要是用ThreadLocal2.1Synchronized、Lock保证线程安全2.2ThreadLocal保证线程安全3.ThreadLocal和Synchronized的区别二、ThreadLocal原理1.Thread抽象内部结构2.ThreadLocal源码2.1Thread、ThreadLocal、ThreadLocalMap、En…

行业观察 | 内存接口芯片和CXL协议

本文对内存接口芯片的概念和CXL协议进行不完全总结。 更新&#xff1a;2022 / 02 / 25 行业观察 | 内存接口芯片背景内存接口芯片概念趋势CXL 协议背景 DRAM 内存基本被国外巨头 三星、美光 等内存模组制造商垄断&#xff0c;合计市场占有率超过 90%。 内存接口芯片 概念 什…