linux交叉编译libnet,交叉编译samba(mipsel-linux) samba-3.3.3.tar.gz

交叉编译samba(mipsel-linux)

这篇文章我从网上下下来的,一直放在草稿箱里,忘了从哪里转来的。感谢原作者,按他的做法能正常移植。

今天完成了交叉编译samba的学习。将samba移植到mipsel-linux平台上。相关工作流程如下。

一:简介

制作mipsel-linux交叉编译工具链;

使用samba-3.3.3.tar.gz源代码;

二:流程

1、在/etc/profile中设置mipsel-linux交叉编译工具路径,执行source指令使之生效;

或者在当前终端标签页中使用export PATH=${bin directory of mipsel-linux}:$PATH

2、解压samba到设定之目录;

3、configure脚本build.sh

***********************************************

#!/bin/bash

export CFLAGS='-O3 -w -isystem /Cross/target/local/mipsel-linux/include'

export CPPFLAGS='-O3 -w -isystem /Cross/target/local/mipsel-linux/include'

export PATH=/Cross/target/local/bin:$PATH

export LD_LIBRARY_PATH=/Cross/target/local/bin/mipsel-linux-gcc

export CC=/Cross/target/local/bin/mipsel-linux-gcc

export CPP=/Cross/target/local/bin/mipsel-linux-cpp

./configure  --build=i686-linux --host=mipsel-linux --target=mipsel-linux \

--includedir=/Cross/target/local/mipsel-linux/include \

--oldincludedir=/Cross/target/local/mipsel-linux/include \

--disable-largefile    \

--enable-swat=no \

--enable-cups=no \

--enable-iprint=no \

--enable-pie=no \

--enable-fam=no \

--enable-static=yes \

--enable-shared-libs=no \

--enable-dnssd=no \

--with-ldap=no \

--with-ads=no \

--with-cifsmount=no \

--with-utmp=no \

--with-libtalloc=no \

--with-libtdb=no \

--with-libnetapi=no \

--with-libaddns=no \

--with-libsmbclient=no \

--with-libsmbsharemodes=no \

--with-acl-support=no \

--with-sendfile-support=no \

--with-winbind=no \

--with-static-modules=nmbd,smbd,smbclient,smbpasswd \

--bindir=$MQARMDIR/bin \

--sbindir=$MQARMDIR/bin \

--localstatedir=$MQUSERDIR/samba/var \

--libdir=$MQARMDIR/lib \

--with-privatedir=$MQUSERDIR/samba/private \

--with-rootsbindir=$MQARMDIR/bin \

--with-lockdir=$MQUSERDIR/samba/var/locks \

--with-configdir=$MQUSERDIR/samba \

--with-logfilebase=$MQUSERDIR/samba/var \

--with-piddir=$MQUSERDIR/samba/var \

--cache-file=mipsel-linux.cache

***********************************************

执行该编译脚本。在编译过程中会出现一些问题,现描述如下:

3.1 error: cannot run test program while cross compiling错误

checking that the C compiler understands negative enum values... configure: error: in `/root/samba-3.3.3/source':

configure: error: cannot run test program while cross compiling

原因:

查找“negative enum values”关键字,就可以找到问题发生的地方。

通常我们configure的时候使用./configure  --build=i686-linux --host=$ARCH-linux --target=$ARCH-linux的形式,但是在configure中有很多的测试程序是不能在HOST上运行的。configure不能为交叉编译检查samba_cv_CC_NEGATIVE_ENUM_VALUES。configure无法在目标机上运行测试程序,自然无法检查,只好手工指定。

解决方法:

#echo samba_cv_CC_NEGATIVE_ENUM_VALUES=yes>mipsel-linux.cache

然后在build.sh脚本中的最后一行添加“--cache-file=mipsel-linux.cache”

如果后面还遇到类似的问题,则之需要找到相关的地方,并将指定的值追加到mipsel-linux.cache文件中。

3.2 configure: error: cannot run test program while cross compiling错误

configure: error: in `/root/samba-3.3.3/source':

configure: error: cannot run test program while cross compiling

See `config.log' for more details.

原因:这个错误是由于configure对交叉编译支持的问题造成的,通过在configure文件中查找,您可以看到原文件中该部分的内容为:

******************************************

{ $as_echo "$as_me:$LINENO: checking for replacing readdir using getdirentries()" >&5

$as_echo_n "checking for replacing readdir using getdirentries()... " >&6; }

if test "${libreplace_cv_READDIR_GETDIRENTRIES+set}" = set; then

$as_echo_n "(cached) " >&6

else

if test "$cross_compiling" = yes; then{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compilingSee \`config.log' for more details." >&5$as_echo "$as_me: error: cannot run test program while cross compilingSee \`config.log' for more details." >&2;}{ (exit 1); exit 1; }; }; }

else

cat >conftest.$ac_ext

上面即为问题出现点,红色字体部分是需要修改的地方。修改后的结果如下:

******************************************

{ $as_echo "$as_me:$LINENO: checking for replacing readdir using getdirentries()" >&5

$as_echo_n "checking for replacing readdir using getdirentries()... " >&6; }

if test "${libreplace_cv_READDIR_GETDIRENTRIES+set}" = set; then

$as_echo_n "(cached) " >&6

else

if test "$cross_compiling" = yes; then{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compilingSee \`config.log' for more details." >&5$as_echo "$as_me: error: cannot run test program while cross compilingSee \`config.log' for more details." >&2;}

}; }    #新增该行#注销该行   { (exit 1); exit 1; }; }; }

else

cat >conftest.$ac_ext

以关键字“error: cannot run test program while cross compiling”查找configure文件,将其中相关代码都修改过来,即可以解决该问题。

3.3 头文件错误

编译过程中会出现找不到头文件的错误,拷贝/usr/include/linux/dqblk_xfs.h文件到mipsel-linux交叉编译工具链的linux/include目录中;

cp /usr/include/linux/dqblk_xfs.h /Cross/target/local/mipsel-linux/include/linux

3.4 库文件连接错误:找不到-lcups

拷贝交叉编译的cups相关库到mipsel-linux交叉编译工具链的lib目录中

cp /crosstool/test/cups/mips/cups-1.3.9/cups/libcups.a /Cross/target/local/mipsel-linux/lib

cp /crosstool/test/cups/mips/cups-1.3.9/cups/libcups.so* /Cross/target/local/mipsel-linux/lib

以上目录需要自己指定您机器上的目录,以上只是本机的目录。

4、make

执行make指令。

三. 配置

[global]

workgroup = MSHOME

unix charset = UTF8

display charset = UTF8

dos charset = UTF8

netbios name = longjindong

dns proxy = no

domain master = no

local master = Yes

preferred master = Yes

os level = 35

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

interfaces = 192.168.1.1/192.168.1.0

guest account = admin

log level = 0

max log size = 10

security = share

load printers = no

[longjindong]

path = /mnt/usb

writable = yes

guest ok = yes

read only = no

四:后记

参考文档:http://blog.csdn.net/robinqcn/archive/2008/10/23/3132054.aspx

欢迎大家讨论cups+samba到开发板的移植。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值