### Android跨平台编译 ---ICONV

// step1: app.gradle

externalNativeBuild {

cmake {

cppFlags "-frtti -fexceptions --std=c++1z"

arguments "-DANDROID_STL=c++_static"

}

}

// step2:然后将最新的iconv代码全部复制到项目的cpp目录下。

// 然后打开命令行,在cpp目录下运行./configure

// step3:cmakeLists.txt

cmake_minimum_required(VERSION 3.4.1)

project(mylib)

add_compile_options(

-Wno-multichar

-DANDROID

-DLIBDIR=\"c\"

-DBUILDING_LIBICONV

-DIN_LIBRARY

)

include_directories(src/main/cpp/)

include_directories(src/main/cpp/include)

include_directories(src/main/cpp/libcharset)

include_directories(src/main/cpp/lib)

include_directories(src/main/cpp/libcharset/include)

include_directories(src/main/cpp/srclib)

add_library( # Sets the name of the library.

iconv

# Sets the library as a static library.

SHARED

# Provides a relative path to your source file(s).

src/main/cpp/libcharset/lib/localcharset.c src/main/cpp/lib/iconv.c src/main/cpp/lib/relocatable.c

)

// step4:修改宏定义 #define HAVE_LANGINFO_CODESET 0

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐