samba交叉编译

来源:互联网 发布:excel去除相同数据 编辑:程序博客网 时间:2024/06/05 21:15

转自: http://hi.baidu.com/jiaolingqi/blog/item/d999931696cca658f3de32a5.html


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

configure --host=arm-linux 这就是arm的交叉编译选项

configure --host=mipsel-linux 这个就是mipsel的交叉编译选项

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

1.设置环境变量
export CPPFLAGS=-I//home/2.8/toolchain_2.8.3.0/build_mipsel_nofpu/staging_dir/include
export LDFLAGS=-L/home/2.8/toolchain_2.8.3.0/build_mipsel_nofpu/staging_dir/lib
export CC=/home/2.8/toolchain_2.8.3.0/build_mipsel_nofpu/staging_dir/bin/mipsel-linux-gcc

2. ./configure --host=i686 --target=mipsel-linux
编译过程中产生一下错误:
checking that the C compiler understands -Werror... cross
checking that the C compiler understands -w2... cross
checking that the C compiler understands volatile... yes
checking that the C compiler understands negative enum values... configure: error: cannot run test program while cross compiling
See `config.log' for more details.
原因:
           查找“checking that the C compiler understands negative enum values”关键字,就可以找到问题发生的地方。
           通常我们configure的时候使用./configure --build=i686-linux --host=$ARCH-linux --target=$ARCH-linux的形式,但是在configure中有很多的测试程序是不能在HOST上运行的configure不能为交叉编译检查SMB_BUILD_CC_NEGATIVE_ENUM_VALUES。configure无法在目标机上运行测试程序,自然无法检查,只好手工指定。

            解决方法(1或2):
          1. 在终端中输入如下命令:
            #echo SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes>mipsel-linux.cache
          2.
if test "${SMB_BUILD_CC_NEGATIVE_ENUM_VALUES+set}" = set; then前加一行

        echo SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=>arm-linux.cache


            然后输入:
            #./configure --host=mipsel-linux --cache-file=arm-linux.cache
            如果后面还遇到类似的问题,则之需要找到相关的地方,并将指定的值追加到mipsel-linux.cache文件中。
===================================================================================
继续运行configure,出现如下的错误:
checking for creat64... yes
checking for prctl... yes
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 compiling
            See \`config.log' for more details." >&5
            $as_echo "$as_me: error: cannot run test program while cross compiling
            See \`config.log' for more details." >&2;}
               { (exit 1); exit 1; }; }; }
            else
            cat >conftest.$ac_ext <<_ACEOF

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

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

            { $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 compiling
            See \`config.log' for more details." >&5
            $as_echo "$as_me: error: cannot run test program while cross compiling
            See \`config.log' for more details." >&2;}
                     }; }    #新增该行
            #注销该行 { (exit 1); exit 1; }; }; }
            else
            cat >conftest.$ac_ext <<_ACEOF

            ******************************************
            以关键字“error: cannot run test program while cross compiling”查找configure文件,将其中相关代码都修改过来,即可以解决该问题。(问题类似:注意括号的配对

===============================================
最后执行make就行了
如果执行make出错,出现error: unterminated #ifndef等问题是因为你的权限不够,可以执行chmod a+x * 试试,还不行的话就重新解压源码包!!
重新编译!!
在编译samba-3.0.23a的时候如果出现:
lib/time.c:60: error: too few arguments to function 'gettimeofday'
修改lib/time.c的第60行gettimeofday(tval);为gettimeofday(tval,NULL);
原创粉丝点击