一、概述
遠(yuǎn)程開關(guān)機(jī)功能需要用到samba里面的一個(gè)工具net
,所以需要交叉編譯samba,并將該工具放到SS528
海思開發(fā)板上運(yùn)行。由于新的代碼太大且 3.3.16 的版本已經(jīng)夠用,所以就沒用最新的代碼。
編譯系統(tǒng):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
- 源碼在 gitee下載地址:https://gitee.com/AndroidTony/samba/tags?page=27
- 在 GitHub 的下載地址:https://github.com/samba-team/samba/releases/tag/samba-3.3.16
本文只要介紹 amba-samba-3.3.16.zip
怎么交叉編譯,以及在編譯過程中遇到的三個(gè)問題怎樣解決。
二、編譯步驟
??2.1 解壓縮,進(jìn)入源碼目錄
unzip samba-samba-3.3.16.zip
cd samba-samba-3.3.16/source/
??2.2 配置
在source
目錄,先執(zhí)行./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
指定運(yùn)行主機(jī); -
--enable-static
:允許編譯靜態(tài)庫 -
--enable-shared=no
:不允許編譯動(dòng)態(tài)態(tài)庫
??2.3 問題一
報(bào)錯(cuò)
報(bào)錯(cuò):
machine 'aarch64-mix210' not recognized
錯(cuò)誤原因分析:
錯(cuò)誤原因分析:
aarch64-mix210 不被識(shí)別,這是指明運(yùn)行主機(jī)的,嘗試改成其他。
解決方案:
解決方案:
改為--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 問題二
報(bào)錯(cuò)
報(bào)錯(cuò):
cannot run test program while cross compiling
錯(cuò)誤打印如下: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
錯(cuò)誤原因分析:
錯(cuò)誤原因分析:
從打印看,是交叉編譯時(shí)無法運(yùn)行測(cè)試程序,交叉編譯的程序肯定無法在Ubuntu運(yùn)行,想辦法規(guī)避。
1、執(zhí)行grep "checking that the C compiler understands negative enum values" -rnw ./
,查看為什么會(huì)打印這個(gè),搜索結(jié)果如下:./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、通過搜索結(jié)果可以看到打印在
./configure:7290
,執(zhí)行命令vi ./configure +7290
打開該位置,看到只要samba_cv_CC_NEGATIVE_ENUM_VALUES
沒設(shè)置值就會(huì)執(zhí)行else去運(yùn)行測(cè)試程序,我們要設(shè)法跳過這個(gè)判斷。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 問題三
報(bào)錯(cuò):
報(bào)錯(cuò):
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
錯(cuò)誤原因分析:
錯(cuò)誤原因分析:
錯(cuò)誤原因和上個(gè)問題一樣,也是運(yùn)行時(shí)交叉編譯的測(cè)試程序
1、先搜索
checking for prctl
,查看為什么會(huì)打印這個(gè),grep "checking for prctl" -rnw ./ ./config.log:67357:configure:15050: checking for prctl
2、通過搜索結(jié)果可以看到在
configure:15050
會(huì)檢查prctl
,執(zhí)行命令vi ./configure +15050
打開該位置,然后往下翻,大概在15090的位置看到執(zhí)行測(cè)試程序的代碼,我們要設(shè)法跳過這些語句。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
解決方案:
解決方案:
我的解決辦法是注釋掉這些語句,注釋后如下圖:
然后繼續(xù)執(zhí)行如下配置命令: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
配置以后,直接執(zhí)行make && make install
,編譯通過。文章來源:http://www.zghlxwxcb.cn/news/detail-464469.html
如果文章有幫助的話,點(diǎn)贊??、收藏?,支持一波,謝謝 ??????文章來源地址http://www.zghlxwxcb.cn/news/detail-464469.html
到了這里,關(guān)于samba-3.3.16 在海思平臺(tái)(SS528)交叉編譯及問題解決的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!