1. 程式人生 > >ndk 交叉編譯BusyBox心得。

ndk 交叉編譯BusyBox心得。



cd ./busybox-1.26.2/

make android2_defconfig

make menuconfig


n file included from include/libbb.h:13,
                 from coreutils/touch.c:82:
include/platform.h:483:6: warning: "__ANDROID_API__" is not defined
include/platform.h:486:8: warning: "__ANDROID_API__" is not defined
include/platform.h:492:6: warning: "__ANDROID_API__" is not defined
coreutils/touch.c: In function 'touch_main':
coreutils/touch.c:167: error: 'lutimes' undeclared (first use in this function)
coreutils/touch.c:167: error: (Each undeclared identifier is reported only once
coreutils/touch.c:167: error: for each function it appears in.)
make[1]: *** [coreutils/touch.o] 錯誤 1
make: *** [coreutils] 錯誤 2
platform.h  391 行定義:#define __ANDROID_API__ 8 後面編譯看的眼花。
無意發現:'lutimes' undeclared 下面官網給的提示:
bool "Add support for -h"
//config:default y
//config:depends on TOUCH
//config:help
//config: Enable touch to have the -h option.
//config: This requires libc support for lutimes() function.


-h 預設開啟。進make menuconfig 設定 coreutils touch -h去掉,完美解決。
不然關閉 touch不太好。


libbb/in_ether.c:12:26: error: net/ethernet.h: No such file or directory


miscutils/i2c_tools.c:66:27: error: linux/i2c-dev.h: No such file or directory




  CC      miscutils/i2c_tools.o
miscutils/i2c_tools.c: In function 'i2c_smbus_write_i2c_block_data':
miscutils/i2c_tools.c:190: error: 'I2C_SMBUS_I2C_BLOCK_BROKEN' undeclared (first use in this function)
miscutils/i2c_tools.c:190: error: (Each undeclared identifier is reported only once
miscutils/i2c_tools.c:190: error: for each function it appears in.)
miscutils/i2c_tools.c: In function 'i2c_smbus_read_i2c_block_data':
miscutils/i2c_tools.c:225: error: 'I2C_SMBUS_I2C_BLOCK_BROKEN' undeclared (first use in this function)
miscutils/i2c_tools.c: In function 'check_funcs_test_end':
miscutils/i2c_tools.c:313: error: 'I2C_FUNC_SMBUS_PEC' undeclared (first use in this function)
miscutils/i2c_tools.c: At top level:
miscutils/i2c_tools.c:1055: error: 'I2C_FUNC_SMBUS_PEC' undeclared here (not in a function)
make[1]: *** [miscutils/i2c_tools.o] 錯誤 1
make: *** [miscutils] 錯誤 2
開啟i2c_tools.c找系統標頭檔案。
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
也沒有linux/i2c.h
後面找標頭檔案的方法和一樣。
linux/i2c.h 定義:I2C_SMBUS_I2C_BLOCK_BROKEN和I2C_FUNC_SMBUS_PEC。




miscutils/nandwrite.c: In function 'nandwrite_main':
miscutils/nandwrite.c:151: error: 'MTD_FILE_MODE_RAW' undeclared (first use in this function)
miscutils/nandwrite.c:151: error: (Each undeclared identifier is reported only once
miscutils/nandwrite.c:151: error: for each function it appears in.)
make[1]: *** [miscutils/nandwrite.o] 錯誤 1
make: *** [miscutils] 錯誤 2
mtd/mtd-abi.h 定義:MTD_FILE_MODE_RAW。




networking/libiproute/ipneigh.c:14:29: error: linux/neighbour.h: No such file or directory
一樣。make 一堆錯誤修復。


networking/libiproute/iproute.c: In function 'print_route':
networking/libiproute/iproute.c:85: error: 'RTA_TABLE' undeclared (first use in this function)
networking/libiproute/iproute.c:85: error: (Each undeclared identifier is reported only once
networking/libiproute/iproute.c:85: error: for each function it appears in.)
networking/libiproute/iproute.c: In function 'iproute_modify':
networking/libiproute/iproute.c:437: error: 'RTA_TABLE' undeclared (first use in this function)


百度搜索:linux RTA_TABLE networking :linux/下
找到了http://blog.csdn.net/gt945/article/details/45315911
很快鎖定目標。linux/rtnetlink.h
In file included from networking/libiproute/iproute.c:13:
networking/libiproute/ip_common.h:10:27: error: linux/if_addr.h: No such file or directory
networking/libiproute/ip_common.h:13:27: error: linux/if_link.h: No such file or directory
出來I早點多好,




networking/libiproute/ll_map.c: In function 'll_remember_index':
networking/libiproute/ll_map.c:47: error: 'IFLA_MAX' undeclared (first use in this function)
networking/libiproute/ll_map.c:47: error: (Each undeclared identifier is reported only once
networking/libiproute/ll_map.c:47: error: for each function it appears in.)
networking/libiproute/ll_map.c:56: warning: implicit declaration of function 'IFLA_RTA'
networking/libiproute/ll_map.c:56: warning: implicit declaration of function 'IFLA_PAYLOAD'
networking/libiproute/ll_map.c:56: warning: passing argument 3 of 'parse_rtattr' makes pointer from integer without a cast
networking/libiproute/libnetlink.h:45: note: expected 'struct rtattr *' but argument is of type 'int'
networking/libiproute/ll_map.c:57: error: 'IFLA_IFNAME' undeclared (first use in this function)
networking/libiproute/ll_map.c:75: error: 'IFLA_ADDRESS' undeclared (first use in this function)
networking/libiproute/ll_map.c:47: warning: unused variable 'tb'
make[1]: *** [networking/libiproute/ll_map.o] 錯誤 1


從網路入手:http://blog.csdn.net/romainxie/article/details/8300443
 
linux/nfnetlink.h


util-linux/blkdiscard.c: In function 'blkdiscard_main':
util-linux/blkdiscard.c:71: error: 'BLKSECDISCARD' undeclared (first use in this function)
util-linux/blkdiscard.c:71: error: (Each undeclared identifier is reported only once
util-linux/blkdiscard.c:71: error: for each function it appears in.)
util-linux/blkdiscard.c:71: error: 'BLKDISCARD' undeclared (first use in this function)
make[1]: *** [util-linux/blkdiscard.o] 錯誤 1
make: *** [util-linux] 錯誤 2
linux/fs.h




util-linux/fstrim.c: In function 'fstrim_main':
util-linux/fstrim.c:53: error: storage size of 'range' isn't known
util-linux/fstrim.c:91: error: invalid application of 'sizeof' to incomplete type 'struct fstrim_range' 
util-linux/fstrim.c:91: error: array type has incomplete element type
util-linux/fstrim.c:91: error: invalid application of 'sizeof' to incomplete type 'struct fstrim_range' 
util-linux/fstrim.c:91: error: invalid application of 'sizeof' to incomplete type 'struct fstrim_range' 
util-linux/fstrim.c:53: warning: unused variable 'range'
make[1]: *** [util-linux/fstrim.o] 錯誤 1


換這個:linux/fs.h解決。


util-linux/setarch.c:57:29: error: sys/personality.h: No such file or directory
util-linux/setarch.c: In function 'setarch_main':
util-linux/setarch.c:82: error: 'PER_LINUX' undeclared (first use in this function)
util-linux/setarch.c:82: error: (Each undeclared identifier is reported only once
util-linux/setarch.c:82: error: for each function it appears in.)
util-linux/setarch.c:86: error: 'PER_LINUX32' undeclared (first use in this function)
util-linux/setarch.c:95: warning: implicit declaration of function 'personality'
make[1]: *** [util-linux/setarch.o] 錯誤 1
make: *** [util-linux] 錯誤 2




util-linux/swaponoff.c: In function 'swap_enable_disable':
util-linux/swaponoff.c:152: warning: implicit declaration of function 'swapoff'
util-linux/swaponoff.c:166: warning: implicit declaration of function 'swapon'
util-linux/swaponoff.c: In function 'do_em_all_in_fstab':
util-linux/swaponoff.c:237: warning: implicit declaration of function 'hasmntopt'
util-linux/swaponoff.c:237: error: 'MNTOPT_NOAUTO' undeclared (first use in this function)
util-linux/swaponoff.c:237: error: (Each undeclared identifier is reported only once
util-linux/swaponoff.c:237: error: for each function it appears in.)
util-linux/swaponoff.c:242: warning: initialization makes pointer from integer without a cast
util-linux/swaponoff.c:250: warning: initialization makes pointer from integer without a cast
util-linux/swaponoff.c:262: warning: implicit declaration of function 'endmntent'
make[1]: *** [util-linux/swaponoff.o] 錯誤 1
make: *** [util-linux] 錯誤 2


linux pc 標頭檔案: mntent.h   定義:MNTOPT_NOAUTO 
#define MNTOPT_NOAUTO"noauto"/* Do not auto mount.  */
或者 加進 swaponoff.c裡。
到這裡基本接近尾聲了。
 LINK    busybox_unstripped
Trying libraries: m
Failed: -Wl,--start-group  -lm  -Wl,--end-group
Output of:
/usr/gcc/bin/arm-linux-androideabi-gcc -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wno-format-security -Wdeclaration-after-statement -Wold-style-definition -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-builtin-printf -Os -o busybox_unstripped -Wl,--sort-common -Wl,--sort-section,alignment -Wl,--gc-sections -Wl,--start-group applets/built-in.o archival/lib.a archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a printutils/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a archival/built-in.o archival/libarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o printutils/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group -Wl,--start-group -lm -Wl,--end-group
==========
util-linux/lib.a(nsenter.o): In function `nsenter_main':
nsenter.c:(.text.nsenter_main+0x1a4): undefined reference to `setns'
util-linux/lib.a(setarch.o): In function `setarch_main':
setarch.c:(.text.setarch_main+0x4c): undefined reference to `personality'
util-linux/lib.a(swaponoff.o): In function `swap_enable_disable':
swaponoff.c:(.text.swap_enable_disable+0x20): undefined reference to `swapoff'
swaponoff.c:(.text.swap_enable_disable+0x80): undefined reference to `swapon'
util-linux/lib.a(swaponoff.o): In function `swap_on_off_main':
swaponoff.c:(.text.swap_on_off_main+0x174): undefined reference to `hasmntopt'
swaponoff.c:(.text.swap_on_off_main+0x194): undefined reference to `hasmntopt'
coreutils/lib.a(sync.o): In function `sync_main':
sync.c:(.text.sync_main+0x8c): undefined reference to `syncfs'
libbb/lib.a(find_mount_point.o): In function `find_mount_point':
find_mount_point.c:(.text.find_mount_point+0x54): undefined reference to `setmntent'
find_mount_point.c:(.text.find_mount_point+0x114): undefined reference to `endmntent'
libbb/lib.a(pw_encrypt.o): In function `pw_encrypt':
pw_encrypt.c:(.text.pw_encrypt+0x4): undefined reference to `crypt'
collect2: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"
make: *** [busybox_unstripped] 錯誤 1






//error: undefined reference to 'setns'
//error: undefined reference to 'personality'
//error: undefined reference to 'swapoff'
//error: undefined reference to 'swapon'
error: undefined reference to 'hasmntopt'
//error: undefined reference to 'syncfs'
error: undefined reference to 'setmntent'
error: undefined reference to 'endmntent'

error: undefined reference to 'crypt'

問題:直接使用syscal:

#include <asm/unistd.h>
# include <sys/syscall.h>

__BEGIN_DECLS

int syscall(int number, ...);

__END_DECLS

非常簡單。

例子:

err =syscall(__NR_swapoff,device);

有幾個引數,就幾個。

相關推薦

ndk 交叉編譯BusyBox心得

cd ./busybox-1.26.2/make android2_defconfig make menuconfig n file included from include/libbb.h:13,                  from coreutils/t

Ubuntu14.04交叉編譯BusyBox

轉載地址:https://blog.csdn.net/Q1302182594/article/details/51345988 1 開發環境     宿主機:Ubuntu14.04(32bit)     開發

ndk交叉編譯兩種方式

方式一,匯出standalone cd <ndk-home> ./build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=<stand-alone-build&

openssl NDK 交叉編譯

移植openssl到android建立工作目錄,並進入12mkdir androidcd android下載原始碼生成交叉編譯工具鏈1$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --arch=arm --install-dir=./toolcha

android NDK 交叉編譯

android中介軟體開發,本來利用NDK就直接生成了一個SO檔案,然後直接打包到APK裡,即可執行,但是由於一般真機是不帶有root許可權的,即使SSH可以解決root許可權,當到了java層,root許可權又失效了。經常碰到operation not permitte

NDK交叉編譯tcpdump實現安卓抓包

下面介紹一下具體過程。 1.Git clone libpcap和tcpdump兩個專案。 git clone https://github.com/the-tcpdump-group/tcpdump.git git clone https://githu

如何在windows上用ndk交叉編譯其他平臺程式

目標       :編譯arm64的.so庫 編譯方法:理論上應該有兩種交叉編譯方法,法一,在Linux伺服器上安裝交叉工具鏈,直接用交叉工具鏈進行編譯連結;法二,使用ndk完成交叉編譯,因為 ndk已經安裝好交叉編譯工具鏈,以及相關的系統庫和系統標頭檔案了。這兩種方法的區

ubuntu14.04+android-ndk-r10b+arm環境下交叉編譯openssl-1.1.1記錄

相關依賴: android-ndk-r10b:ubuntu14.04搭建Android-NDK開發環境 android-arm:ubuntu14.04搭建Android-arm交叉編譯環境 1.開啟一個新的Terminal,進入Android平臺工作空間:cd AndroidWork

如何用NDK建立一個標準的android環境交叉編譯工具鏈(Cross Toolchain)

轉自:http://blog.sina.com.cn/s/blog_4a0a39c30101q1u4.htmlhttp://www.linuxidc.com/Linux/2014-11/109905.htmandroid原始碼在 prebuilts 目錄已經自帶有交叉編譯工具

如何用NDK建立一個標準的交叉編譯工具鏈(Cross Toolchain)

   android ndk好象從 r5b 開始,就在 build/tools 目錄準備了一個 make-standalone-toolchain.sh的程式來讓使用者建立標準的交叉編譯工具鏈(Cross Toolchain),以最新的ndkr8e為例,一般建議在ndk的要目錄執行如下命令: $ ./buil

使用 Android NDK交叉編譯工具鏈移植 C/C++ 專案到安卓平臺

什麼是 NDK? Android NDK 是一套可以讓開發者在安卓應用開發中使用 C/C++ 實現特定模組的工具集,不是所有應用都需要用到,但是正確地使用可以有效提高應用執行效率和安全性。 為什麼要在安卓開發中使用 NDK? 遊戲引擎使用 Native 的 C/C++

Ubuntu下安裝配置NDK、獨立交叉編譯工具編譯C/C++程式

Android中IDE、ADT、SDK、JDK、NDK的解釋 1. IDE:Intelligent Development Environm的簡稱。即智慧開發環境。是一種開發工具。常用的IDE有adt-bundles和Android studio。兩個都需要配置jdk

busybox交叉編譯+移植

二,busybox的編譯報錯解決 $化妝 1.loginutils / passwd.c:104:16:錯誤:儲存大小 增加標頭檔案解決 $ VIM的Linux /普通/ buildroot的/建設/ busybox的-1.18.3 /有/ libbb.h 的#include <SYS / RESO

Linux交叉編譯(Android-NDK-r5)

最近一段時間在做Kobo專案,主要是Android-ndk-r5的交叉編譯,有一個已經寫好了的程式庫,但是呢,是用vc寫的,而Android裡面的Java是不能直接呼叫VC寫的程式碼,所以我們需要將vc寫的程式庫交叉編譯成Java能呼叫的.so動態連結庫。 首先,是使用ubu

Golang 交叉編譯

一.golang支援在一個平臺下生成另一個平臺可執行程式的交叉編譯功能, 1.Mac下編譯Linux,windows平臺的64位可執行程式:   CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build main.go   CGO_ENABLE=0 GOOS=windo

linux-ubuntu16.04 為樹莓派3B 交叉編譯qt5.9 心得

樹莓派3B  系統為2016.11.25的 jessie  交叉編譯器版本:4.9.4 主機版本:ubuntu 16.04 64位 參考資料:https://www.ics.com/blog/building-qt-5-raspberry-pi   https://www.

如何用NDK建立一個標準的android環境交叉編譯工具鏈(Cross Toolchain)(轉)

android原始碼在 prebuilts 目錄已經自帶有交叉編譯工具鏈,但這個還不是一個標準的可直接編譯程式碼的編譯器,還需要依賴android ndk 的標頭檔案及庫檔案,才能進行編譯和連結,且版本也比較保守(4.0原始碼自帶的是gcc 4.4.3,

linux下3.4.1交叉編譯器編譯busybox-1.20.2

一、移植:busybox-1.20.0並且使用strace解決問題 2、解壓:tarxvf busybox-1.20.0.tar.bz2 3、配置:cd busybox-1.20.0                 make menuconfig 4、配置選項新增交叉編譯

NDK在Ubuntu14.04上安裝arm交叉編譯環境

之前沒有接觸過交叉編譯,後來因為在實驗室要在機器人上跑arm程式,所以就嘗試著用Ubuntu來編譯arm的程式,自己上網查方法並諮詢了很多同學同事,最終搭建成功了這個交叉編譯環境。 由於NDK中帶有一整套arm的gcc和g++編譯器,庫和檔案,所以用NDK安裝

ARM-Linux平臺的Busybox交叉編譯

http://blog.mcuol.com/User/lyusheng/Article/4797_1.htm ARM-Linux平臺的Busybox 交叉編譯           什麼是Busybox呢?            從名字上直接理解,Busybox是一個“繁