iconv.h android,android ndk - NDK and iconv.h dependency - Stack Overflow

博主在使用Android NDK构建项目时,尝试将libiconv库纳入编译,遇到`localcharset.c`编译错误,涉及`langinfo.h`缺失。文章详细描述了配置过程、错误排查及可能的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I'm trying to build a lib with Adroid NDK which depends on iconv.h

This is what I did so far:

I created a project structure like this:

/jni

- Android.mk

- Application.mk

/jni/zxing

- all my lib source files requiring iconv.h

/external/libiconv-1.13.1

- libiconv sources downloaded from here http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz

Here is my jni/Android.mk file:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := libiconv

LOCAL_CFLAGS := \

-Wno-multichar \

-D_ANDROID \

-DLIBDIR="c" \

-DBUILDING_LIBICONV \

-DIN_LIBRARY

LOCAL_SRC_FILES := \

../external/libiconv-1.13.1/lib/iconv.c \

../external/libiconv-1.13.1/libcharset/lib/localcharset.c \

../external/libiconv-1.13.1/lib/relocatable.c

LOCAL_C_INCLUDES += \

../external/libiconv-1.13.1/include \

../external/libiconv-1.13.1/libcharset \

../external/libiconv-1.13.1/libcharset/include

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := libzxing

LOCAL_SRC_FILES := \

zxing/DecodeHints.cpp \

zxing/ReaderException.cpp \

...and many more...

LOCAL_C_INCLUDES += \

../external/libiconv-1.13.1/include

LOCAL_STATIC_LIBRARIES := libiconv

include $(BUILD_SHARED_LIBRARY)

So, then I run "./configure && make" from /external/libiconv-1.13.1 in order to generate iconv.h from iconv.h.in

Then I run ndk-build from /jni/zxing

All my zxing now compiles without a problem.

/external/libiconv-1.13.1/lib/iconv.h compiles as well

Whereas /external/libiconv-1.13.1/libcharset/lib/localcharset.c gives me the following error:

lib/localcharset.c:49:24: error: langinfo.h: No such file or directory

My guess is that I did something wrong while doing ./configure && make on libiconv as the inclusion of "langinfo.h" is conditioned by HAVE_LANGINFO_CODESET defined in libiconv-1.13.1/config.h which in turn comes from libiconv-1.13.1/config.h.in...

BTW, if I force HAVE_LANGINFO_CODESET to 0, then I have others error while compiling localcharset.c

So, I'm out of ideas :(

Can some one help me please?

Thanks, Luca.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值