strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.77k stars 306 forks source link

Build failure: `decoder_jpeg.cc: operator '&&' has no right operand` #1382

Closed mertalev closed 1 week ago

mertalev commented 1 week ago

Hi! I'm trying to upgrade my libheif build script from 1.18.2 to 1.19.3, but encountered this error:

#23 117.1 /usr/src/app/libheif/heifio/decoder_jpeg.cc:43:75: error: operator '&&' has no right operand
#23 117.1    43 | #if defined(LIBJPEG_TURBO_VERSION_NUMBER) && LIBJPEG_TURBO_VERSION_NUMBER == 2000000

libheif is built with this command:

cmake --preset=release-noplugins \
    -DWITH_DAV1D=ON \
    -DENABLE_PARALLEL_TILE_DECODING=ON \
    -DENABLE_LIBSHARPYUV=ON \
    -DENABLE_LIBDE265=ON \
    -DWITH_AOM_DECODER=OFF \
    -DWITH_AOM_ENCODER=OFF \
    -DWITH_X265=OFF \
    -DWITH_EXAMPLES=OFF \
    ..
make install

This is the specific GitHub workflow that failed.

bradh commented 1 week ago

Those ENABLE_LIBDE265 and ENABLE_LIBSHARPYUV should probably be WITH_x - this got cleaned up.

I can't reproduce the failure locally. Possibly we aren't detecting the JPEG library (or lack of) correctly for this docker build.

mertalev commented 1 week ago

Thanks for this tip!

The Dockerfile installs libjpeg62-turbo-dev before this. Maybe the error is related to this?

farindk commented 1 week ago

The error message seems to indicate that LIBJPEG_TURBO_VERSION_NUMBER is defined to be empty. I get the error only for a test program like this:

#define LIB123 123
#define LIBJPEG_TURBO_VERSION_NUMBER

#if defined(LIB123) && LIBJPEG_TURBO_VERSION_NUMBER == 2000000

If LIBJPEG_TURBO_VERSION_NUMBER is not defined at all, I don't get that error.

That means that probably something is wrong with your libjpeg package. Search for that constant in the libjpeg header files and what it is set to.

mertalev commented 1 week ago

I changed the Dockerfile to end at the previous build step and searched for LIBJPEG_TURBO_VERSION_NUMBER. There are actually two entries:

root@2362ec38616b:/usr/src/app# grep -rnw '/usr' -e 'LIBJPEG_TURBO_VERSION_NUMBER'
/usr/local/include/jconfig.h:10:#define LIBJPEG_TURBO_VERSION_NUMBER  
/usr/include/aarch64-linux-gnu/jconfig.h:10:#define LIBJPEG_TURBO_VERSION_NUMBER  2001005

The first one comes from jpegli, so it seems there's some kind of misconfiguration there.

mertalev commented 1 week ago

I fixed it by adding -DLIBJPEG_TURBO_VERSION_NUMBER=2001005 to the libjxl build script's cmake command.

farindk commented 1 week ago

Thanks for the feedback.