分类: SQLite/嵌入式数据库
2011-06-27 18:59:45
附件是我改好了的iperf代码,讲其解压到*/external/iperf。
之后在最顶层目录,
$ cd mydroid $ source build/envsetup.sh $ make iperf -j8 就搞定了。不过我这个iperf是X86版本的。下面是我做的详细过程。
1. 下载iperf-2.0.4.tar.gz
2. 解压到mydroid/external/iperf
3. 使用autoconf自动配置,并生成config.h
$ ./configure --host=x86 ac_cv_func_malloc_0_nonnull=yes
必须添加ac_cv_func_malloc_0_nonnull=yes,否则编译时会报错undefined reference to `rpl_malloc'
4. 创建Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
compat/Thread.c \
compat/error.c \
compat/delay.cpp \
compat/gettimeofday.c \
compat/inet_ntop.c \
compat/inet_pton.c \
compat/signal.c \
compat/snprintf.c \
compat/string.c
LOCAL_SRC_FILES += \
src/Client.cpp \
src/Extractor.c \
src/Launch.cpp \
src/List.cpp \
src/Listener.cpp \
src/Locale.c \
src/PerfSocket.cpp \
src/ReportCSV.c \
src/ReportDefault.c \
src/Reporter.c \
src/Server.cpp \
src/Settings.cpp \
src/SocketAddr.c \
src/main.cpp \
src/sockets.c \
src/stdio.c \
src/tcp_window_size.c \
src/gnu_getopt.c \
src/gnu_getopt_long.c \
src/service.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH) \
$(LOCAL_PATH)/include
LOCAL_CFLAGS += -O2
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_LDLIBS += -lpthread
LOCAL_SHARED_LIBRARIES := libc libm libcutils libnetutils
LOCAL_MODULE := iperf
#LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng user
include $(BUILD_EXECUTABLE)
5. 编译
$ cd mydroid
$ source build/envsetup.sh
$ mmm external/iperf
编译报错:
external/testtools/iperf/compat/signal.c:135: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'my_signal'
经查原因为:iperf/include/util.h与bionic/libc/include/util.h冲突导致
解决方法:因搞不清如何改变include的先后顺序,所以用稍笨一点但很简单的方法进行解决,将util.h另存一份为util_iperf.h,同时将所有包含util.h的地方改为util_iperf.h
再次编译仍有报错:
external/testtools/iperf/src/Listener.cpp:382: error: 'struct ipv6_mreq' has no member named 'ipv6mr_interface'
经查bionic/libc/kernel/common/linux/In6.h中的定义为
struct ipv6_mreq {
struct in6_addr ipv6mr_multiaddr;
int ipv6mr_ifindex;
};
确实不存在ipv6mr_interface了,所以将382行改为mreq.ipv6mr_ifindex = 0;
至此编译完成,下载到目标板上,可以执行。还未使用此工具进行性能测试,未知上述方法编译的程序是否存在问题。待验证