Ubuntu 18.04交叉编译机顶盒samba软件

本文介绍嵌入式samba功能实现,包含编译环境搭建,使用arm-linux-gcc交叉编译工具。先在X86平台编译测试samba-3.0.37,再交叉编译arm平台,解决编译中出现的问题。还说明了在机顶盒创建工作目录和配置文件,最后在win10中进行访问测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考资料:
嵌入式samba功能的实现,linux下samba的移植 https://blog.youkuaiyun.com/ternence_hsu/article/details/70241669

编译环境

操作系统
xy@ubuntu18xx:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
交叉编译工具
arm-linux-gcc-4.4.3-20100728.tar.gz
xy@ubuntu18xx:~$ env|grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:.:/opt/FriendlyARM/toolschain/4.4.3/bin
xy@ubuntu18xx:~$ arm-linux-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/configure --build=i386-build_redhat-linux-gnu --host=i386-build_redhat-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.4.3 --with-sysroot=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root --enable-languages=c,c++ --disable-multilib --with-arch=armv4t --with-cpu=arm920t --with-tune=arm920t --with-float=soft --with-pkgversion=ctng-1.6.1 --disable-sjlj-exceptions --enable-__cxa_atexit --with-gmp=/opt/FriendlyARM/toolschain/4.4.3 --with-mpfr=/opt/FriendlyARM/toolschain/4.4.3 --with-ppl=/opt/FriendlyARM/toolschain/4.4.3 --with-cloog=/opt/FriendlyARM/toolschain/4.4.3 --with-mpc=/opt/FriendlyARM/toolschain/4.4.3 --with-local-prefix=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-c99 --enable-long-long --enable-target-optspace
Thread model: posix
gcc version 4.4.3 (ctng-1.6.1)

下载和解压

curl -O https://download.samba.org/pub/samba/samba-3.0.37.tar.gz
tar zxvf samba-3.0.37.tar.gz
cd samba-3.0.37/source/

先在X86平台上面进行编译测试:

./configure samba_cv_CC_NEGATIVE_ENUM_VALUES=yes
make
不需要修改,可以直接编译通过
这里用的root用户测试,需要修改一下权限,后面用xy用户编译
root@ubuntu18xx:/home/xy/c/samba# chmod -R 777 .

再交叉编译arm平台

xy@ubuntu18xx:~/c/samba/samba-3.0.37/source$ ./configure samba_cv_CC_NEGATIVE_ENUM_VALUES=yes CC=arm-linux-gcc LD=arm-linux-ld ranlid=arm-linux-ranlid AR=arm-linux-ar --target=arm-linux --host=i686

checking that the C compiler understands volatile… yes
checking that the C compiler understands negative enum values… configure: error: in /home/xy/c/samba/samba-3.0.37/source': configure: error: cannot run test program while cross compiling Seeconfig.log’ for more details.
config.log
configure:11454: arm-linux-gcc -c -O -D_SAMBA_BUILD_=3 conftest.c >&5
configure:11461: ? = 0 c o n f i g u r e : 11476 : r e s u l t : y e s c o n f i g u r e : 11491 : c h e c k i n g t h a t t h e C c o m p i l e r u n d e r s t a n d s n e g a t i v e e n u m v a l u e s c o n f i g u r e : 11498 : e r r o r : i n ‘ / h o m e / x y / c / s a m b a / s a m b a − 3.0.37 / s o u r c e ′ : c o n f i g u r e : 11501 : e r r o r : c a n n o t r u n t e s t p r o g r a m w h i l e c r o s s c o m p i l i n g S e e ‘ c o n f i g . l o g ′ f o r m o r e d e t a i l s . 修 改 c o n f i g u r e 文 件 11497 i f t e s t " ? = 0 configure:11476: result: yes configure:11491: checking that the C compiler understands negative enum values configure:11498: error: in `/home/xy/c/samba/samba-3.0.37/source': configure:11501: error: cannot run test program while cross compiling See `config.log' for more details. 修改configure文件 11497 if test " ?=0configure:11476:result:yesconfigure:11491:checkingthattheCcompilerunderstandsnegativeenumvaluesconfigure:11498:error:in/home/xy/c/samba/samba3.0.37/source:configure:11501:error:cannotruntestprogramwhilecrosscompilingSeeconfig.logformoredetails.configure11497iftest"cross_compiling" = yes; then
先修改为no
samba_cv_CC_NEGATIVE_ENUM_VALUES=yes 应该把这个参数修改为no试试的
配置通过

make报错
Compiling smbd/server.c
mkdir bin
Linking bin/smbd
param/loadparm.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Makefile:967: recipe for target ‘bin/smbd’ failed
make: *** [bin/smbd] Error 1
xy@ubuntu18xx:~/c/samba/samba-3.0.37/source$
xy@ubuntu18xx:~/c/samba/samba-3.0.37/source$ ll param/loadparm.o
-rwxrwxrwx 1 root root 216568 May 22 15:42 param/loadparm.o*
xy@ubuntu18xx:~/c/samba/samba-3.0.37/source$ file param/loadparm.o
param/loadparm.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
第一次make的文件没有清除
mv param/*o bin_x86_64
mv lib/*o bin_x86_64
mv smbd/*o bin_x86_64/
mv printing/o bin_x86_64/
rm -r bin_x86_64
rm modules/
.o
rm libsmb/*o
rm rpc_parse/o
find . -name "
.o" | xargs file |grep “ELF 64” | awk '{ print $1 } ’ > a 开始没有增加64位关键字,把所有的o文件都删除了。
awk -F: ‘{ print "rm " $1}’ a > rma
make编译成功 bin/smbd

机顶盒上面:

创建工作目录:
mkdir /usr/local /usr/local/samba /usr/local/samba/bin /usr/local/samba/lib /usr/local/samba/private /usr/local/samba/var
创建配置文件: vi /usr/local/samba/lib/smb.conf
[global]
workgroup = myworkgroup
server string = samba
netbios name =myarm
guest account=root
security =share
interfaces = eth0
[share]
path = /opt/
guest ok=yes
browseable=yes

bin/smbd 到 开发板的 /usr/local/samba/bin 目录下面;
/usr/local/samba/bin/smbd -D
准备测试文件 cat /proc/cpuinfo > /opt/cpu.txt

在win10中访问测试

打开 \192.168.1.1 提示因为文件共享不安全,所以你不能连接到文件共享
此共享需要旧的 SMB1 协议,它不安全,并且可能使你的系统受到攻击。
你的系统需要 SMB2 或更高版本。 有关解决此问题的详细信息,请参阅:https://go.microsoft.com/fwlink/?linkid=852747

cortana中搜索:启用或关闭Windows功能,选中SMB1.0/CIFS 客户端,重启仍然不能访问,需要3个都安装重启,正常访问\192.168.1.1,无密码提示。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值