2012-04-11 65 views
0

我打算通过NDK 1.7将端口保险丝2.8.7插入到Android中首先,我应该通过android toolchain构建保险丝项目,然后将其注入到android内核中作为但不幸的是,我在编译过程中遇到了一些问题。 这里是细节: 1:保险丝2.8.7项目文件夹内,我建立一个shell脚本如下:关于通过Android工具链(NDK)构建保险丝

#!/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 

回答

0

我相信你需要android内核头文件来构建模块,而NDK肯定会做不是包含android内核头文件。看看Can the android NDK compile kernel module source?以获得更多有关编译Android内核模块信息的链接。但是请注意。这是一个多毛的世界编译Android的内核模块相比,Linux的,由于(该编译器编译内核对你正在构建的模块等为例)

4

尝试更换包含SYS/statvfs.h的信息较少in fuse.h by this:

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

根据[本答案](http://stackoverflow.com/a/8489426/3427520),第一行应该是'#ifndef __ANDROID__'。 – zwcloud 2017-01-04 17:22:31