Open-iScsi 编译

build open-iscsi from source

foreversmart write on 2022-12-17
首先获取 open-iscsi 的源码
open-iscsi 新版本没有用make 来编译而是是通过 meson 来进行源码编译

Meson 安装或者升级

meson 是一个快速友好的编译构建工具, 类似与 Makefile,automake,cmake 等等
安装 meson ninja
apt 安装的 meson 的版本太低 4.*
需要通过安装 pip 来进行安装,这里 meson 需要 python 的版本大于 3.7
apt install python3.7
ln -s /usr/bin/python3.7 /usr/bin/python
升级 pip 到当前 python 版本
python -m pip install --upgrade pip
pip install meson ninja

构建项目依赖

通过 meson 构建
mkdir builddir
meson builddir
构建会报错 还需要 cmake ,pkg-config
apt install pkg-config
apt install cmake
继续构建
C
Copy
Run-time dependency libkmod found: NO (tried pkgconfig and cmake) meson.build:84:0: ERROR: Dependency "libkmod" not found, tried pkgconfig and cmake
apt-get install -y libkmod-dev
继续构建
C
Copy
The Meson build system Version: 0.64.1 Source dir: /root/ror_kube/src/open-iscsi Build dir: /root/ror_kube/src/open-iscsi/builddir Build type: native build Project name: open-iscsi Project version: 2.1.8 C compiler for the host machine: cc (gcc 7.5.0 "cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0") C linker for the host machine: cc ld.bfd 2.30 Host machine cpu family: x86_64 Host machine cpu: x86_64 Program list-man-pages.sh found: YES (/root/ror_kube/src/open-iscsi/libopeniscsiusr/docs/list-man-pages.sh) Program kernel-doc found: YES (/root/ror_kube/src/open-iscsi/libopeniscsiusr/docs/kernel-doc) Found pkg-config: /usr/bin/pkg-config (0.29.1) Run-time dependency libkmod found: YES 24 Found CMake: /usr/bin/cmake (3.10.2) DEPRECATION: CMake support for versions <3.17 is deprecated since Meson 0.62.0. | | However, Meson was only able to find CMake 3.10.2. | | Support for all CMake versions below 3.17.0 will be removed once | newer CMake versions are more widely adopted. If you encounter | any errors please try upgrading CMake to a newer version first. Run-time dependency libcrypto found: NO (tried pkgconfig, system and cmake) meson.build:85:0: ERROR: Dependency "libcrypto" not found, tried pkgconfig, system and cmake
apt install openssl
apt install libssl-dev
继续构建
C
Copy
Run-time dependency mount found: NO (tried pkgconfig and cmake)
apt-get install libmount-dev
继续构建
C
Copy
Found CMake: /usr/bin/cmake (3.10.2) DEPRECATION: CMake support for versions <3.17 is deprecated since Meson 0.62.0. | | However, Meson was only able to find CMake 3.10.2. | | Support for all CMake versions below 3.17.0 will be removed once | newer CMake versions are more widely adopted. If you encounter | any errors please try upgrading CMake to a newer version first. Run-time dependency libsystemd found: NO (tried pkgconfig and cmake) meson.build:88:2: ERROR: Dependency "libsystemd" not found, tried pkgconfig and cmake
升级 cmake
ln -sf cmake-3.25/bin/* /usr/bin/
cmake --version
升级完 cmake 后还是报上面的错误
apt install libsystemd-dev 可能是 libsystemd 版本太低
继续构建
C
Copy
meson.build:184:0: ERROR: C shared or static library 'isns' not found
这个是因为 open-iscsi 需要 open-isns 这个库
两种选择:
我们可以源码编译 https://github.com/open-iscsi/open-isns
通过 apt 安装
Shell
Copy
apt list | grep isns # 安装 apt install libisns-dev
继续构建:
发现可以成功了

编译

构建完成以后需要通过 ninja 命令编译成可执行文件
Shell
Copy
ninja -C builddir DESTDIR=<SOME-DIR> ninja -C builddir install # 安装可执行文件和配置文件 # 如果不指定 DESTDIR 默认目录是 / DESTDIR=/root/ror_kube/src/build ninja -C builddir install
到编译好的目录
进入到 builddir 里面 执行 ./iscsiadm --version 发现已经可以成功运行了
注意:
千万不要卸载删除操作系统原有的cmake,否则之前经过原有cmake编译过的文件将也会被删除,比如 ros。下面的语句会卸载删除操作系统的 cmake
Plain Text
Copy
sudo apt-get autoremove cmake
参考:

「真诚赞赏,手留余香」

Foreversmart

真诚赞赏,手留余香

使用微信扫描二维码完成支付