首页 > 代码库 > libiconv build in android

libiconv build in android

以编译libiconv-1.13.1为例1,安装 NDK  设置安装NDK环境变量 ANDROID_NDK_ROOT (自行定义)2,获取源码     $ mkdir libiconv    $ cd libiconv    $ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz3,解压,    $ tar zxvf libiconv-1.13.1.tar.gz4,把liniconv-1.13.1重命名为jni    $ mv libiconv-1.13.1 jni5,创建Android.mk文件    $ cd jni    $ vim Android.mk复制一下内容到Android.mk中保存并且退出    LOCAL_PATH:= $(call my-dir)#libiconv.soinclude $(CLEAR_VARS)LOCAL_MODULE := libiconvLOCAL_CFLAGS :=   -Wno-multichar   -DANDROID   -DLIBDIR="c"   -DBUILDING_LIBICONV   -DIN_LIBRARYLOCAL_SRC_FILES :=   libcharset/lib/localcharset.c   lib/iconv.c   lib/relocatable.cLOCAL_C_INCLUDES +=   $(LOCAL_PATH)/include   $(LOCAL_PATH)/libcharset   $(LOCAL_PATH)/lib   $(LOCAL_PATH)/libcharset/include   $(LOCAL_PATH)/srclibinclude $(BUILD_SHARED_LIBRARY)6,配置    生成linux环境下的config.h文件    $ ./configure7,make    $ make8,执行编译     $ $ANDROID_NDK_ROOT/ndk-build V=18.1、编译时提示:libiconv-1.14/jni/libcharset/lib/localcharset.c:51:24: error: langinfo.h: No such file or directory解决方法:修改目录文件libcharset/config.h的宏定义,禁止该宏定义:/* Define if you haveand nl_langinfo(CODESET). */#define HAVE_LANGINFO_CODESET 08.2、提示错误:报“c undeclaired”错误解决方法:修改文件/libcharset/lib/localcharset.c中函数get_charset_aliases (void)搜索:int c;把该变量定义放到该函数的开始处8.3 继续执行编译     $ $ANDROID_NDK_ROOT/ndk-build V=1此时编译完成在目录jni/libs/armeabi-v7a下会有libiconv.so库文件

 

libiconv build in android