关于通过android工具链(NDK)构建保险丝

时间:2012-04-11 08:09:54

标签: android android-ndk fuse

我打算通过NDK 1.7将保险丝2.8.7移植到android中 首先,我应该通过android工具链构建融合项目,然后将其作为模块注入到android内核中。但不幸的是,我在编译期间遇到了一些问题。 以下是详细信息: 1:在保险丝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,构建项目,并提示以下错误:

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

2 个答案:

答案 0 :(得分:4)

尝试用fuse:

替换fuse.h中的sys / statvfs.h
#ifndef ANDROID
#  include <sys/statvfs.h>
#else
#  include <sys/vfs.h>
#  define statvfs statfs
#endif

答案 1 :(得分:0)

我相信你需要安装android内核头来构建模块,而NDK肯定会 NOT 包含android内核头文件。请查看Can the android NDK compile kernel module source?以获取有关为Android编译内核模块的更多信息的链接。但请注意。与Linux相比,由于信息较少(例如哪个编译器编译了您正在构建模块的内核等等),因此编译Android的内核模块是一个更加繁荣的世界。