Android编译器是否支持-Wall? [英] Does Android compiler honor -Wall?

查看:176
本文介绍了Android编译器是否支持-Wall?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我们的 Android.mk .共享库基于C ++库.

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)

库的构建基本上可以.某些选项是 not 不被接受,例如-Wall.其他选项,如-Wl,--exclude-libs,ALL都受到重视.

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

Android.mk的文档在这里,但未讨论删除或过滤选项.

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

为什么Android的构建系统无法兑现我们所有的标志?

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"

奇怪的是,我们所有的源文件都是C ++,并且没有任何源文件是使用-Wall构建的.但是,我们导入了Android的cpufeatures库,它是一个C源文件,并且是使用-Wall:

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

鉴于我使用的是LOCAL_CPP_FLAGS := -Wall,我想会发生相反的情况-所有C ++源文件都将使用-Wall构建,而一个C文件将不使用-Wall构建.

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.

推荐答案

这只是一个错字,您需要LOCAL_CPPFLAGS,那里只需要一个_.

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

对于cpu-features.c,它收到-Wall,因为$(NDK_ROOT)/sources/android/cpufeatures/Android.mkLOCAL_CFLAGS中需要此.

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

这篇关于Android编译器是否支持-Wall?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆