分类: LINUX
2009-06-04 14:29:34
软件环境:linux
由于iperf使用了autoconf,所以iperf的编译借助了另一个编译器(arm-none-linux-gnueabi)来生成config.h、Makefile等配置
1. 下载iperf-
2. 解压到mydroid/external/iperf
3. 使用autoconf自动配置,并生成config.h,先确保gnueabi编译器可以正确编译
$ export PATH=/usr/local/arm-none-linux-gnueabi/bin:$PATH
$ ./configure --host=arm-none-linux-gnueabi 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;
至此编译完成,下载到目标板上,可以执行。还未使用此工具进行性能测试,未知上述方法编译的程序是否存在问题。待验证