android编译 cryptopp,Android编译器是否支持-Wall?

I'm trying to build a shared object with the following recipe in our Android.mk. The shared object is based on a C++ library.

include $(CLEAR_VARS)

LOCAL_MODULE := cryptopp_shared

LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),$(CRYPTOPP_SRC_FILES))

LOCAL_CPP_FLAGS := -Wall

LOCAL_CPP_FEATURES := rtti exceptions

LOCAL_LDFLAGS := -Wl,--exclude-libs,ALL -Wl,--as-needed

LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/..

LOCAL_STATIC_LIBRARIES := cpufeatures

include $(BUILD_SHARED_LIBRARY)

The library builds mostly OK. Some options are not being honored, like -Wall. Other options like -Wl,--exclude-libs,ALL are being honored.

The docs for Android.mk is here, but it does not discuss removing or filtering options.

Why is Android's build system not honoring all of our flags?

Here is the build command we used. I build from the library's root directory:

ndk-build V=1 APP_ABI=armeabi-v7a NDK_PROJECT_PATH="$PWD" \

NDK_APPLICATION_MK="$PWD/Application.mk"

The odd thing is, all of our source files are C++ and none of the source files were built with -Wall. However, we import Android's cpufeatures library, it is one C source file, and it was built with -Wall:

/opt/android-ndk-r16b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -MMD -MP -

MF /home/cryptopp/obj/local/armeabi-v7a/objs/cpufeatures/cpu-features.o.d -gcc-t

oolchain /opt/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/lin

ux-x86_64 -fpic -ffunction-sections -funwind-tables -fstack-protector-strong -Wn

o-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-

prefixes -fno-integrated-as -g -target armv7-none-linux-androideabi18 -march=arm

v7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -DNDEBUG -I/opt/android-ndk

-r16b/sources/android/cpufeatures -DANDROID -Wall -Wextra -Werror -D__ANDROID_

API__=18 -Wa,--noexecstack -Wformat -Werror=format-security --sysroot /opt/andr

oid-ndk-r16b/sysroot -isystem /opt/android-ndk-r16b/sysroot/usr/include/arm-linu

x-androideabi -c /opt/android-ndk-r16b/sources/android/cpufeatures/cpu-features

.c -o /home/cryptopp/obj/local/armeabi-v7a/objs/cpufeatures/cpu-features.o

Given I used LOCAL_CPP_FLAGS := -Wall I would think the opposite would happen - all C++ source files would build with -Wall, and the one C file would build without.

解决方案

It's a mere typo, you need LOCAL_CPPFLAGS, only one _ there.

As for cpu-features.c, it receives -Wall because $(NDK_ROOT)/sources/android/cpufeatures/Android.mk requires this in LOCAL_CFLAGS.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值