簡體   English   中英

關於通過 android 工具鏈(NDK)構建保險絲

[英]about build the fuse via android toolchain(NDK)

我打算通過 NDK 1.7 將保險絲 2.8.7 移植到 android 首先,我應該通過 android 工具鏈構建保險絲項目,然后將其作為模塊注入 android kernel。但不幸的是,我在編譯過程中遇到了一些問題。 這是細節: 1:在 fuse 2.8.7 項目文件夾中,我構建了一個 shell 腳本,如下所示:

#!/bin/sh
# Compiles fftw3 for Android
export NDK_ROOT="/home/kaiwii/android_related/android-ndk-r7b"
export PATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/:$PATH"
export SYS_ROOT="$NDK_ROOT/platforms/android-14/arch-arm/"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip"

./configure --host=arm-eabi  LIBS="-lc -lgcc"

make
make install

exit 0

2、build項目,提示如下錯誤:

In file included from fuse_i.h:9,
                 from fuse.c:13:
../include/fuse.h:33:25: error: sys/statvfs.h: No such file or directory
In file included from fuse_i.h:9,
                 from fuse.c:13:
../include/fuse.h:207: warning: 'struct statvfs' declared inside parameter list
../include/fuse.h:207: warning: its scope is only this definition or declaration, which is probably not what you want
../include/fuse.h:721: warning: 'struct statvfs' declared inside parameter list
In file included from fuse_i.h:10,
                 from fuse.c:13:
../include/fuse_lowlevel.h:1021: warning: 'struct statvfs' declared inside parameter list
In file included from fuse.c:13:
fuse_i.h:29: error: expected specifier-qualifier-list before 'pthread_mutex_t'
fuse_i.h:60: error: expected specifier-qualifier-list before 'pthread_mutex_t'
In file included from fuse.c:18:
../include/fuse_compat.h:32: warning: 'struct statvfs' declared inside parameter list
fuse.c:1036: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'convert_statfs_compat':
fuse.c:1038: error: dereferencing pointer to incomplete type
fuse.c:1039: error: dereferencing pointer to incomplete type
fuse.c:1040: error: dereferencing pointer to incomplete type
fuse.c:1041: error: dereferencing pointer to incomplete type
fuse.c:1042: error: dereferencing pointer to incomplete type
fuse.c:1043: error: dereferencing pointer to incomplete type
fuse.c:1044: error: dereferencing pointer to incomplete type
fuse.c: At top level:
fuse.c:1047: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'convert_statfs_old':
fuse.c:1049: error: dereferencing pointer to incomplete type
fuse.c:1050: error: dereferencing pointer to incomplete type
fuse.c:1051: error: dereferencing pointer to incomplete type
fuse.c:1052: error: dereferencing pointer to incomplete type
fuse.c:1053: error: dereferencing pointer to incomplete type
fuse.c:1054: error: dereferencing pointer to incomplete type
fuse.c:1055: error: dereferencing pointer to incomplete type
fuse.c: At top level:
fuse.c:1059: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'fuse_compat_statfs':
fuse.c:1064: warning: passing argument 2 of 'fs->op.statfs' from incompatible pointer type
fuse.c:1064: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1070: warning: passing argument 2 of 'convert_statfs_old' from incompatible pointer type
fuse.c:1047: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1077: warning: passing argument 2 of 'convert_statfs_compat' from incompatible pointer type
fuse.c:1035: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c: At top level:
fuse.c:1376: warning: 'struct statvfs' declared inside parameter list
fuse.c:1376: error: conflicting types for 'fuse_fs_statfs'
../include/fuse.h:721: note: previous declaration of 'fuse_fs_statfs' was here
fuse.c: In function 'fuse_fs_statfs':
fuse.c:1383: warning: passing argument 3 of 'fuse_compat_statfs' from incompatible pointer type
fuse.c:1058: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1385: error: dereferencing pointer to incomplete type
fuse.c:1386: error: dereferencing pointer to incomplete type
fuse.c: In function 'fuse_lib_statfs':
fuse.c:2878: error: storage size of 'buf' isn't known
fuse.c:2878: warning: unused variable 'buf'
fuse.c: In function 'locks_insert':
fuse.c:3056: warning: comparison is always true due to limited range of data type
fuse.c: In function 'lock_to_flock':
fuse.c:3138: warning: comparison is always false due to limited range of data type
make[1]: *** [fuse.lo] Error 1
make[1]: Leaving directory `/home/kaiwii/test/fuse-2.8.7/lib'
make: *** [all-recursive] Error 1
Making install in include
make[1]: Entering directory `/home/kaiwii/test/fuse-2.8.7/include'
make[2]: Entering directory `/home/kaiwii/test/fuse-2.8.7/include'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/include/fuse" || /bin/mkdir -p "/usr/local/include/fuse"
 /usr/bin/install -c -m 644 fuse.h fuse_compat.h fuse_common.h fuse_common_compat.h fuse_lowlevel.h fuse_lowlevel_compat.h fuse_opt.h cuse_lowlevel.h '/usr/local/include/fuse'
test -z "/usr/local/include" || /bin/mkdir -p "/usr/local/include"
 /usr/bin/install -c -m 644 old/fuse.h ulockmgr.h '/usr/local/include'
make[2]: Leaving directory `/home/kaiwii/test/fuse-2.8.7/include'
make[1]: Leaving directory `/home/kaiwii/test/fuse-2.8.7/include'
Making install in lib
make[1]: Entering directory `/home/kaiwii/test/fuse-2.8.7/lib'
/bin/bash ../libtool --tag=CC   --mode=compile arm-linux-androideabi-gcc --sysroot=/home/kaiwii/android_related/android-ndk-r7b/platforms/android-14/arch-arm/ -DHAVE_CONFIG_H -I. -I../include  -I../include -DFUSERMOUNT_DIR=\"/usr/local/bin\" -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26   -Wall -W -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -g -O2 -fno-strict-aliasing -MT fuse.lo -MD -MP -MF .deps/fuse.Tpo -c -o fuse.lo fuse.c
libtool: compile:  arm-linux-androideabi-gcc --sysroot=/home/kaiwii/android_related/android-ndk-r7b/platforms/android-14/arch-arm/ -DHAVE_CONFIG_H -I. -I../include -I../include -DFUSERMOUNT_DIR=\"/usr/local/bin\" -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26 -Wall -W -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -g -O2 -fno-strict-aliasing -MT fuse.lo -MD -MP -MF .deps/fuse.Tpo -c fuse.c -o fuse.o
In file included from fuse_i.h:9,
                 from fuse.c:13:
../include/fuse.h:33:25: error: sys/statvfs.h: No such file or directory
In file included from fuse_i.h:9,
                 from fuse.c:13:
../include/fuse.h:207: warning: 'struct statvfs' declared inside parameter list
../include/fuse.h:207: warning: its scope is only this definition or declaration, which is probably not what you want
../include/fuse.h:721: warning: 'struct statvfs' declared inside parameter list
In file included from fuse_i.h:10,
                 from fuse.c:13:
../include/fuse_lowlevel.h:1021: warning: 'struct statvfs' declared inside parameter list
In file included from fuse.c:13:
fuse_i.h:29: error: expected specifier-qualifier-list before 'pthread_mutex_t'
fuse_i.h:60: error: expected specifier-qualifier-list before 'pthread_mutex_t'
In file included from fuse.c:18:
../include/fuse_compat.h:32: warning: 'struct statvfs' declared inside parameter list
fuse.c:1036: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'convert_statfs_compat':
fuse.c:1038: error: dereferencing pointer to incomplete type
fuse.c:1039: error: dereferencing pointer to incomplete type
fuse.c:1040: error: dereferencing pointer to incomplete type
fuse.c:1041: error: dereferencing pointer to incomplete type
fuse.c:1042: error: dereferencing pointer to incomplete type
fuse.c:1043: error: dereferencing pointer to incomplete type
fuse.c:1044: error: dereferencing pointer to incomplete type
fuse.c: At top level:
fuse.c:1047: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'convert_statfs_old':
fuse.c:1049: error: dereferencing pointer to incomplete type
fuse.c:1050: error: dereferencing pointer to incomplete type
fuse.c:1051: error: dereferencing pointer to incomplete type
fuse.c:1052: error: dereferencing pointer to incomplete type
fuse.c:1053: error: dereferencing pointer to incomplete type
fuse.c:1054: error: dereferencing pointer to incomplete type
fuse.c:1055: error: dereferencing pointer to incomplete type
fuse.c: At top level:
fuse.c:1059: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'fuse_compat_statfs':
fuse.c:1064: warning: passing argument 2 of 'fs->op.statfs' from incompatible pointer type
fuse.c:1064: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1070: warning: passing argument 2 of 'convert_statfs_old' from incompatible pointer type
fuse.c:1047: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1077: warning: passing argument 2 of 'convert_statfs_compat' from incompatible pointer type
fuse.c:1035: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c: At top level:
fuse.c:1376: warning: 'struct statvfs' declared inside parameter list
fuse.c:1376: error: conflicting types for 'fuse_fs_statfs'
../include/fuse.h:721: note: previous declaration of 'fuse_fs_statfs' was here
fuse.c: In function 'fuse_fs_statfs':
fuse.c:1383: warning: passing argument 3 of 'fuse_compat_statfs' from incompatible pointer type
fuse.c:1058: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1385: error: dereferencing pointer to incomplete type
fuse.c:1386: error: dereferencing pointer to incomplete type
fuse.c: In function 'fuse_lib_statfs':
fuse.c:2878: error: storage size of 'buf' isn't known
fuse.c:2878: warning: unused variable 'buf'
fuse.c: In function 'locks_insert':
fuse.c:3056: warning: comparison is always true due to limited range of data type
fuse.c: In function 'lock_to_flock':
fuse.c:3138: warning: comparison is always false due to limited range of data type
make[1]: *** [fuse.lo] Error 1
make[1]: Leaving directory `/home/kaiwii/test/fuse-2.8.7/lib'
make: *** [install-recursive] Error 1

嘗試通過以下方式替換 fuse.h 中包含的 sys/statvfs.h:

#ifndef ANDROID
#  include <sys/statvfs.h>
#else
#  include <sys/vfs.h>
#  define statvfs statfs
#endif

我相信您需要 android kernel 標頭來構建模塊,而 NDK 絕對包含 android kernel 標頭。 看看Can the android NDK compile kernel module source? 有關為 Android 編譯 kernel 模塊的更多信息的鏈接。但是請注意。 與 Linux 相比,為 Android 編譯 kernel 模塊是一個毛茸茸的世界,因為信息較少(例如,哪個編譯器編譯了 kernel,您正在構建模塊等)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM