MolotovCherry / Android-ImageMagick7

Fully featured, latest builds of imagemagick 7 for Android. Featuring a full build of very many libraries (delegates)
170 stars 52 forks source link

error: variable 'output' set but not used [-Werror,-Wunused-but-set-variable] #97

Closed Haidar0096 closed 2 years ago

Haidar0096 commented 2 years ago

I forked this repo, cloned it to my windows 11 pc, and edited the application.mk file like this:

...
HDRI_ENABLE   := false
# 8, 16, 32
QUANTUM_DEPTH := 8
...
STATIC_BUILD     := false
# magick bin requires magick wand API
BUILD_MAGICK_BIN := true
BUILD_MAGICKWAND := true
# requires magickwand
BUILD_MAGICKPP   := true

And I edited build-release.bat like this:

...
path-to-my-ndk-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 

Now I ran build-release.bat like this: .\build-release.bat.

The build starts but at the end I get 3 errors:

././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.

I tried adding APP_CFLAGS += -Wno-error (also for cpp flags), but nothing changed.

MolotovCherry commented 2 years ago

Could you try the flag -Wno-unused-but-set-variable?

Not completely sure yet, but could be something with the clang version

Haidar0096 commented 2 years ago

Could you try the flag -Wno-unused-but-set-variable?

Not completely sure yet, but could be something with the clang version

I tried as you suggested, but I got the same errors:

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

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

and the errors are the same:

...
[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....
Haidar0096 commented 2 years ago

Could you try the flag -Wno-unused-but-set-variable?

Not completely sure yet, but could be something with the clang version

I am also getting a ton of warnings although I already set the enable hdri flag to false:

...
[arm64-v8a] Compile        : magickcore-7 <= svg.c
[arm64-v8a] Compile        : magickcore-7 <= url.c
In file included from ././ImageMagick-7.1.0-51/coders/jpeg.c:46:
In file included from ./ImageMagick-7.1.0-51/MagickCore/studio.h:35:
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:86:3: warning: "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to   
      configure time default" [-W#warnings]
# warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default"In file included from
././ImageMagick-7.1.0-51/coders/msl.c:  ^44
:
In file included from ./ImageMagick-7.1.0-51/MagickCore/studio.h:./ImageMagick-7.1.0-51/MagickCore/magick-config.h35::
87:3./ImageMagick-7.1.0-51/MagickCore/magick-config.h:: 86:3warning: : "this is an obsolete behavior please fix yours makefile" warning: [-W#warnings]
"you# warning "this is an obsolete behavior please fix yours makefile"
should   ^set
 MAGICKCORE_HDRI_ENABLE to sensible default set it to
      configure time default" [-W#warnings]
# warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default"
  ^
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:87:3: warning: "this is an obsolete behavior please fix yours makefile" [-W#warnings] 
# warning "this is an obsolete behavior please fix yours makefile"
  ^
In file included from ././ImageMagick-7.1.0-51/coders/svg.c:43:
In file included from ./ImageMagick-7.1.0-51/MagickCore/studio.h:35:
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:86:3: warning: "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to   
      configure time default" [-W#warnings]
# warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default"
  ^
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:87:3: warning: "this is an obsolete behavior please fix yours makefile" [-W#warnings] 
# warning "this is an obsolete behavior please fix yours makefile"
  ^
In file included from ././ImageMagick-7.1.0-51/coders/url.c:43:
In file included from ./ImageMagick-7.1.0-51/MagickCore/studio.h:35:
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:86:3: warning: "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to   
      configure time default" [-W#warnings]
# warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default"
  ^
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:87:3: warning: "this is an obsolete behavior please fix yours makefile" [-W#warnings] 
# warning "this is an obsolete behavior please fix yours makefile"
  ^
In file included from ././ImageMagick-7.1.0-51/coders/jpeg.c:77:
./ImageMagick-7.1.0-51/MagickCore/quantum-private.h:401:28: warning: implicit conversion from 'long' to 'float' changes value from      
      72340172838076673 to 72340177116200960 [-Wimplicit-const-int-float-conversion]
In file included from ././ImageMagick-7.1.0-51/coders/msl.c  return((MagickSizeType) (72340172838076673*quantum+0.5));
:80                           ^~~~~~~~~~~~~~~~~~:

./ImageMagick-7.1.0-51/MagickCore/quantum-private.h:401:28: warning: implicit conversion from 'long' to 'float' changes value from      
      72340172838076673 to 72340177116200960 [-Wimplicit-const-int-float-conversion]
  return((MagickSizeType) (72340172838076673*quantum+0.5));
                           ^~~~~~~~~~~~~~~~~~
In file included from ././ImageMagick-7.1.0-51/coders/svg.c:72:
./ImageMagick-7.1.0-51/MagickCore/quantum-private.h:401:28: warning: implicit conversion from 'long' to 'float' changes value from
      72340172838076673 to 72340177116200960 [-Wimplicit-const-int-float-conversion]
  return((MagickSizeType) (72340172838076673*quantum+0.5));
                           ^~~~~~~~~~~~~~~~~~
In file included from ././ImageMagick-7.1.0-51/coders/url.c:55:
./ImageMagick-7.1.0-51/MagickCore/quantum-private.h:401:28: warning: implicit conversion from 'long' to 'float' changes value from      
      72340172838076673 to 72340177116200960 [-Wimplicit-const-int-float-conversion]
  return((MagickSizeType) (72340172838076673*quantum+0.5));
                           ^~~~~~~~~~~~~~~~~~
3 warnings generated.
[arm64-v8a] Compile        : magickcore-7 <= magick.c
In file included from ././ImageMagick-7.1.0-51/MagickCore/magick.c:43:
In file included from ./ImageMagick-7.1.0-51/MagickCore/studio.h:35:
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:86:3: warning: "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to   
      configure time default" [-W#warnings]
# warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default"
  ^
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:87:3: warning: "this is an obsolete behavior please fix yours makefile" [-W#warnings] 
# warning "this is an obsolete behavior please fix yours makefile"
  ^
2 warnings generated.
[arm64-v8a] Compile        : magickcore-7 <= profile.c
In file included from ././ImageMagick-7.1.0-51/MagickCore/profile.c:42:
In file included from ./ImageMagick-7.1.0-51/MagickCore/studio.h:35:
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:86:3: warning: "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to   
      configure time default" [-W#warnings]
# warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default"
  ^
./ImageMagick-7.1.0-51/MagickCore/magick-config.h:87:3: warning: "this is an obsolete behavior please fix yours makefile" [-W#warnings]
# warning "this is an obsolete behavior please fix yours makefile"
  ^
In file included from ././ImageMagick-7.1.0-51/MagickCore/profile.c:63:
./ImageMagick-7.1.0-51/MagickCore/quantum-private.h:401:28: warning: implicit conversion from 'long' to 'float' changes value from      
      72340172838076673 to 72340177116200960 [-Wimplicit-const-int-float-conversion]
  return((MagickSizeType) (72340172838076673*quantum+0.5));
                           ^~~~~~~~~~~~~~~~~~
3 warnings generated.
3 warnings generated.
[arm64-v8a] Compile        : tiff <= tif_jpeg.c
[arm64-v8a] Compile        : tiff <= tif_ojpeg.c
3 warnings generated.
[arm64-v8a] Compile        : xml2 <= SAX.c
[arm64-v8a] Compile        : xml2 <= entities.c
3 warnings generated.
[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:2572:9: error: variable 'output' set but not used [-Werror,-Wunused-but-set-variable]
    int output = 0;
        ^
././libxml2-2.9.9/encoding.c:2570:9: error: variable 'writtentot' set but not used [-Werror,-Wunused-but-set-variable]
    int writtentot = 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....
MolotovCherry commented 2 years ago

I tested your configuration in a test build, and it works 100%. You can find the generated binary files here in the build below.

https://github.com/MolotovCherry/Android-ImageMagick7/actions/runs/3322017564

Probably what happened is that your configuration is different from the builder environment, e.g. clang version and ndk version.

I'm currently using ndk 23. Could you try it with that? It also may be easier to use GitHub Actions to do it since it's already setup to work.

Probably this is something that should be mentioned in the docs if that indeed is what the problem was.

Haidar0096 commented 2 years ago

Maybe its the ndk version, I am using version 25.1.8937393, I will try to build them using the github actions.

MolotovCherry commented 2 years ago

I added a note to docs to use ndk 23, should hopefully prevent confusion later.

Haidar0096 commented 2 years ago

So I had time to try doing the build on windows using ndk 23, and indeed the problem was from the ndk, so I am closing this now.

MolotovCherry commented 2 years ago

So I had time to try doing the build on windows using ndk 23, and indeed the problem was from the ndk, so I am closing this now.

Thanks for confirming! I'll make sure this is clearly documented