How to compile libiconv Library Based on Android ndk in Linux

Source: Internet
Author: User

Libiconv is an open-source library that provides transcoding functions across platforms. It provides a conversion function: iconv () to implement conversion between different encodings, the libxml2 library compilation on the Android platform requires the libiconv library. Therefore, the libiconv library must be compiled to compile libxml2 Based on Android ndk. Therefore, the libiconv library is compiled and analyzed, the operation is successful and recorded accordingly. For details about how to build the compiling environment of the android ndk platform, refer to other blog posts I wrote. The following describes how to compile the android ndk environment of the libiconv library. If reprinted please keep this Article Source: http://www.shanzhashu.info/archives/220.html

First, download the latest libiconv Library: composer from the official website. First, configure the libiconv library in the Linux environment, that is, execute Configure on the libiconv library to produce the config in the Linux environment. h file, because the config. h defines macros on many Linux platforms. Installation Method: First, $. /configure, then $ make, and then build android. put the MK file in the JNI directory.
Android. mk file content:

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)/srclib  include $(BUILD_SHARED_LIBRARY)#testinclude $(CLEAR_VARS)LOCAL_MODULE :=genutf8LOCAL_SRC_FILES := tests/genutf8.cLOCAL_C_INCLUDES += \  $(LOCAL_PATH)/include \  $(LOCAL_PATH)/libcharset \  $(LOCAL_PATH)/lib \  $(LOCAL_PATH)/libcharset/include \  $(LOCAL_PATH)/srclibLOCAL_SHARED_LIBRARIES := libiconvinclude $(BUILD_EXECUTABLE)

 

Run $ ndk-build

1. Compile prompt:

Libiconv-1.14/JNI/libcharset/lib/localcharset. C: 51: 24: Error: langinfo. h: no such file or directory

Solution:

Modify the macro definition of libcharset/config. h In the directory file to disable the macro definition:

/* Define if you haveand nl_langinfo (codeset ).*/

# Define have_langinfo_codeset 0

2. error message:

"C undeclaired" error reported

Solution:

Modify the get_charset_aliases (void) function in the file/libcharset/lib/localcharset. C)

Search: int C;

Put the variable definition at the beginning of the function.

Run $ ndk-build to compile libiconv. so successfully.

To the libs/armeabi-v7a directory you can find.

If you run the program, you need to package it into the Android platform.

This article from: Hawthorn blog, reproduced please keep the link: http://www.shanzhashu.info/archives/220.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.