概述
本人最近研究samba的源码,但是在源码编译的时候,本以为直接config,make,make install。没想到编译过程中碰到很多麻烦,主要是各种依赖问题。
 基于此,本文把samba编译的详细过程记录下来,以供再次研究借鉴。
软件环境
本文描述到的版本都是比较新的,不同的版本操作会有差异,比如早期samba用python2现在是python3,对应依赖的环境不一样的。
1、Ubuntu:版本23.10,下载地址:https://releases.ubuntu.com/23.10.1/ubuntu-23.10.1-desktop-amd64.iso?_ga=2.172672484.632513974.1697782264-614902196.1697782264
 2、Samba源码:版本4.19.2,下载地址:https://download.samba.org/pub/samba/samba-4.19.2.tar.gz
 3、辅助源码包nettle :版本3.9,下载地址:https://ftp.gnu.org/gnu/nettle/nettle-3.9.tar.gz
 4、辅助源码包gnutls:版本3.7.10,下载地址:https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/gnutls-3.7.10.tar.xz
编译准备
ubuntu23.10是新安装的,下载的测试包放在目录:/home/shen/testCompileSamba
1、为了快速下载更新依赖包,我选择更新镜像源,如果认为有必要可以参考另外一篇文章:https://blog.csdn.net/shenweihong/article/details/133973517?spm=1001.2014.3001.5501
 2、一些基本的命令
 sudo apt-get update
 sudo apt-get upgrade
 sudo apt-get install build-essential make gcc vim
 嘿嘿,这里镜像源作用体现了,不换要二三十分钟,换了两三分钟。
 3、下载解压需要的包
 cd /home/shen/testCompileSamba
 下载
 wget https://download.samba.org/pub/samba/samba-4.19.2.tar.gz
 wget https://ftp.gnu.org/gnu/nettle/nettle-3.9.tar.gz
 wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/gnutls-3.7.10.tar.xz
 解压
 tar -xvf samba-4.19.2.tar.gz
 tar -xvf nettle-3.9.tar.gz
 tar -xvf gnutls-3.7.10.tar.xz
初步配置
进入samba源码
 cd /home/shen/testCompileSamba/samba-4.19.2/
 配置命令:
 ./configure --enable-debug --with-ads --with-systemd --with-winbind
 报错
 
 cat /home/shen/testCompileSamba/samba-4.19.2/bin/config.log,看最后几行:
 
 安装命令解决:sudo apt-get install python-dev-is-python3
 重新再配置
 ./configure --enable-debug --with-ads --with-systemd --with-winbind
 
 cat /home/shen/testCompileSamba/samba-4.19.2/bin/config.log,看最后几行:
 
 这是缺少程序gnutls
 本人用了很多apt-get install都未能解决,很麻烦,因此就用到了源码nettle-3.9.tar.gz和gnutls-3.7.10.tar.xz
安装gnutls
进入gnutls源码
 cd /home/shen/testCompileSamba/gnutls-3.7.10/
 配置命令
 ./configure
 报错:*** Libnettle 3.6 was not found.
 还需要依赖nettle包
进入nettle源码
 cd /home/shen/testCompileSamba/nettle-3.9
 配置命令
 ./configure
 成功
 make
 报错:m4 ./m4-utils.m4 ./asm.m4 config.m4 machine.m4 aes-decrypt-internal.asm >aes-decrypt-internal.s
 /bin/sh: 1: m4: not found
 命令:sudo apt-get install m4
 再make
 成功
 查看命令 ls | grep .so
 camellia-absorb.c
 camellia-absorb.o
 camellia-absorb.o.d
 libnettle.so
 少了libhogweed.so,后面用到没有会报错,还需要调整
 命令:sudo apt-get install libgmp-dev
 然后
 ./configure
 make
 ls | grep .so查看
 camellia-absorb.c
 camellia-absorb.o
 camellia-absorb.o.d
 libhogweed.so
 libnettle.so
 这就有了
 命令sudo make install
回到gnutls源码
 cd /home/shen/testCompileSamba/gnutls-3.7.10/
 ./configure
 还是报错:*** Libnettle 3.6 was not found.
 这是我当时很纠结的地方,明明已经安装了nettle,还是包这个包没有
查看/usr/local/lib64/是否有刚刚编译库文件
 命令:ls /usr/local/lib64/
 libhogweed.a libhogweed.so libhogweed.so.6 libhogweed.so.6.7 libnettle.a libnettle.so libnettle.so.8 libnettle.so.8.7 pkgconfig
 应该没错
 sudo mkdir /usr/lib/pkgconfig/
 sudo ln -s /usr/local/lib64/pkgconfig/nettle.pc /usr/lib/pkgconfig/nettle.pc
 sudo ln -s /usr/local/lib64/pkgconfig/hogweed.pc /usr/lib/pkgconfig/hogweed.pc
复制lib64中nettle库到lib(我偷懒全部复制):sudo cp -r /usr/local/lib64/* /usr/local/lib/
下面这几个命令是尝试的,不知道是否有必要
 sudo apt-get install libcurl4-gnutls-dev
 sudo apt-get install -y gnutls-bin
 sudo apt-get install libffi-dev
尝试其他各种发现下面这个命令起作用
 sudo apt-get install pkg-config
 继续./configure
 报错
 
 安装依赖包命令:sudo apt-get install libtasn1-6-dev
 继续./configure
 报错
 
安装依赖包命令:sudo apt-get install libunistring-dev
 继续./configure
 报错
 
 这个错表示p11-kit不存在,或者版本低于0.23.1,但是我这里明明有了更新版本0.25.0,如下图
 
我猜可能是没有特定的版本,很久都没解决,并且不需要pkcs11,直接跳过去
 配置命令改成:./configure --without-p11-kit
 通过了
make
 sudo make install
 gnutls编译好了
继续配置samba
cd /home/shen/testCompileSamba/samba-4.19.2
 ./configure --enable-debug --with-ads --with-systemd --with-winbind
 报错:
 
 继续配置:./configure --enable-debug --with-ads --with-systemd --with-winbind
 
 sudo apt-get install flex
 类似的后面根据提示安装依赖
 sudo apt-get install bison
 sudo apt-get install libgpgme11-dev
 sudo apt-get install libjansson-dev
 sudo apt-get install libarchive-dev
 sudo apt-get install libacl1-dev
 sudo apt-get install libldap2-dev
 继续配置:./configure --enable-debug --with-ads --with-systemd --with-winbind
 报错
 
 依赖命令:sudo apt-get -y install libparse-yapp-perl
继续配置:./configure --enable-debug --with-ads --with-systemd --with-winbind
 报错
 
 依赖命令:sudo apt-get install libpam0g-dev
 继续配置:./configure --enable-debug --with-ads --with-systemd --with-winbind
 报错:
 
 依赖命令:sudo apt-get install libdbus-1-dev
 继续配置:./configure --enable-debug --with-ads --with-systemd --with-winbind
 报错:
 
 依赖命令:sudo apt-get install python3-markdown
 继续配置:./configure --enable-debug --with-ads --with-systemd --with-winbind
 报错:
 
依赖命令:sudo apt-get install python3-dnspython
 继续配置:./configure --enable-debug --with-ads --with-systemd --with-winbind
 通过
编译
make
 报错
 
 依赖命令:apt-get install libpopt-dev
 再make
 没有报错,后面的运行估计会很麻烦,本文就介绍到这里吧。