c++ error:使用Android NDK编译时,设置了变量但未使用

nr9pn0ug  于 2023-08-09  发布在  Android
关注(0)|答案(1)|浏览(102)

我试图从this repo编译并生成一个共享库。该过程由ndk-build命令启动。我在编译阶段遇到一个错误:
开始编译的ndk命令是:

C:\sdks\Android\Sdk\ndk\25.1.8937393\build\ndk-build --output-sync=none NDK_PROJECT_PATH=./ NDK_APPLICATION_MK=Application.mk APP_BUILD_SCRIPT=Android.mk NDK_OUT=./build/ NDK_LIBS_OUT=./jniLibs -j 4

字符串
产出:

...
[arm64-v8a] Compile        : xml2 <= encoding.c
[arm64-v8a] Compile        : xml2 <= error.c
[arm64-v8a] Compile        : xml2 <= parserInternals.c
././libxml2-2.9.9/encoding.c:2397:12: error: variable 'writtentot' set but not used [-Werror,-Wunused-but-set-variable]
    size_t writtentot = 0;
           ^
././libxml2-2.9.9/encoding.c:2570:9: error: variable 'writtentot' set but not used [-Werror,-Wunused-but-set-variable]
    int writtentot = 0;
        ^
././libxml2-2.9.9/encoding.c:2572:9: error: variable 'output' set but not used [-Werror,-Wunused-but-set-variable]
    int output = 0;
        ^
3 errors generated.
make: *** [C:/sdks/Android/Sdk/ndk/25.1.8937393/build/../build/core/build-binary.mk:422: build//local/arm64-v8a/objs/xml2/./libxml2-2.9.9/encoding.o] Error 1
make: *** Waiting for unfinished jobs....


我理解错误:则该警告被设置为被视为错误。
我尝试通过将以下内容添加到application.mk文件来禁用此行为:

APP_CFLAGS   += -O3
APP_CFLAGS   += -Wno-unused-but-set-variable

APP_CPPFLAGS += -O3
APP_CPPFLAGS += -Wno-unused-but-set-variable


但一切都没有改变。
如何禁用ndk-build传递给编译器的标志,这是导致此错误的原因?

6tqwzwtp

6tqwzwtp1#

我通过在文件cflags.mk中添加以下行来解决这个问题:

LOCAL_CFLAGS    += -Wno-unused-but-set-variable

字符串

相关问题