samba-3.3.16 在海思平台(SS528)交叉编译及问题解决


在这里插入图片描述

一、概述

远程开关机功能需要用到samba里面的一个工具net,所以需要交叉编译samba,并将该工具放到SS528海思开发板上运行。由于新的代码太大且 3.3.16 的版本已经够用,所以就没用最新的代码。

编译系统:Linux virtual-machine 5.4.0-84-generic #94~18.04.1-Ubuntu SMP Thu Aug 26 23:17:46 UTC 2021
编译器:aarch64-mix210-linux-gcc (gcc version 7.3.0 (20220321) )
编译源码:samba-samba-3.3.16

本文只要介绍 amba-samba-3.3.16.zip怎么交叉编译,以及在编译过程中遇到的三个问题怎样解决。

在这里插入图片描述

二、编译步骤

👉2.1 解压缩,进入源码目录

unzip samba-samba-3.3.16.zip
cd samba-samba-3.3.16/source/

👉2.2 配置

source目录,先执行./autogen.sh生成configure,然后配置

./autogen.sh
./configure --prefix=`pwd`/../../result_samba CC=aarch64-mix210-linux-gcc --host=aarch64-mix210-linux --enable-static --enable-shared=no
  • --prefix=pwd/../../result_samba:指定安装目录在../../result_samba
  • CC=aarch64-mix210-linux-gcc:指定编译器,--host指定运行主机;
  • --enable-static:允许编译静态库
  • --enable-shared=no:不允许编译动态态库

👉2.3 问题一

报错

报错:machine 'aarch64-mix210' not recognized
在这里插入图片描述

错误原因分析:

错误原因分析:
aarch64-mix210 不被识别,这是指明运行主机的,尝试改成其他。

解决方案:

解决方案:
改为 --host=arm-mix210-linux,改完命令如下:

./configure --prefix=`pwd`/../../result_samba CC=aarch64-mix210-linux-gcc --host=arm-mix210-linux --enable-static --enable-shared=no

👉2.4 问题二

报错

报错:cannot run test program while cross compiling
错误打印如下:

checking that the C compiler understands volatile... yes
checking that the C compiler understands negative enum values... configure: error: in `/home/samba/01_libCompile/002_samba/samba-samba-3.3.16/source':
configure: error: cannot run test program while cross compiling
See `config.log' for more details

错误原因分析:

错误原因分析:
从打印看,是交叉编译时无法运行测试程序,交叉编译的程序肯定无法在Ubuntu运行,想办法规避。
1、执行grep "checking that the C compiler understands negative enum values" -rnw ./,查看为什么会打印这个,搜索结果如下:

./configure:7289:{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that the C compiler understands negative enum values" >&5
./configure:7290:$as_echo_n "checking that the C compiler understands negative enum values... " >&6; }
./config.log:4462:configure:7289: checking that the C compiler understands negative enum values

2、通过搜索结果可以看到打印在./configure:7290,执行命令vi ./configure +7290打开该位置,看到只要 samba_cv_CC_NEGATIVE_ENUM_VALUES没设置值就会执行else去运行测试程序,我们要设法跳过这个判断。

7291 if ${samba_cv_CC_NEGATIVE_ENUM_VALUES+:} false; then :
7292   $as_echo_n "(cached) " >&6
7293 else

解决方案:

解决方案:
./configure 命令前加上samba_cv_CC_NEGATIVE_ENUM_VALUES=yes

samba_cv_CC_NEGATIVE_ENUM_VALUES=yes ./configure --prefix=`pwd`/../../result_samba CC=aarch64-mix210-linux-gcc --host=arm-mix210-linux --enable-static --enable-shared=no

👉2.5 问题三

报错:

报错:cannot run test program while cross compiling

在这里插入图片描述

checking for creat64... yes
checking for prctl... yes
configure: error: in `/home/samba/01_libCompile/002_samba/samba-samba-3.3.16/source':
configure: error: cannot run test program while cross compiling
See `config.log' for more details

错误原因分析:

错误原因分析:

错误原因和上个问题一样,也是运行时交叉编译的测试程序

1、先搜索checking for prctl,查看为什么会打印这个,

grep "checking for prctl" -rnw ./
./config.log:67357:configure:15050: checking for prctl

2、通过搜索结果可以看到在configure:15050会检查prctl,执行命令vi ./configure +15050打开该位置,然后往下翻,大概在15090的位置看到执行测试程序的代码,我们要设法跳过这些语句。

15085 case "$host_os" in
15086     *linux*)
15087        # glibc <= 2.3.2 has a broken getgrouplist
15088        if test "$cross_compiling" = yes; then :
15089   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in `$ac_pwd':" >&5
15090 $as_echo "$as_me: error: in `$ac_pwd':" >&2;}
15091 as_fn_error $? "cannot run test program while cross compiling
15092 See `config.log' for more details" "$LINENO" 5; }
15093 else

解决方案

解决方案:

我的解决办法是注释掉这些语句,注释后如下图:
在这里插入图片描述
然后继续执行如下配置命令:

samba_cv_CC_NEGATIVE_ENUM_VALUES=yes ./configure --prefix=`pwd`/../../result_samba CC=aarch64-mix210-linux-gcc --host=arm-mix210-linux --enable-static --enable-shared=no

配置以后,直接执行make && make install,编译通过。

在这里插入图片描述
如果文章有帮助的话,点赞👍、收藏⭐,支持一波,谢谢 😁😁😁

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇

)">
下一篇>>