libjxl / libjxl

JPEG XL image format reference implementation
BSD 3-Clause "New" or "Revised" License
2.47k stars 243 forks source link

windows: build error with msys2+clang : "no matching function for call to 'DGifCloseFile'" #420

Closed vtorri closed 3 years ago

vtorri commented 3 years ago

Describe the bug

[ 90%] Building CXX object lib/CMakeFiles/jxl_extras-static.dir/extras/codec_apng.cc.obj
E:/Documents/programmes_x64/msys2/home/vtorri/gitroot_64/jpeg-xl/lib/extras/codec_gif.cc:35:51: error: no matching function for call to 'DGifCloseFile'
  void operator()(GifFileType* const ptr) const { DGifCloseFile(ptr, nullptr); }
                                                  ^~~~~~~~~~~~~
E:/Documents/programmes_x64/msys2/opt/ewpi_64/include\gif_lib.h:182:5: note: candidate function not viable: requires single argument 'GifFile', but 2 arguments were provided
int DGifCloseFile(GifFileType * GifFile);
    ^
1 error generated.

To Reproduce

I use this script:

#! /bin/sh

rm -rf builddir && mkdir builddir && cd builddir

cmake \
    -DCMAKE_TOOLCHAIN_FILE=../cross_toolchain.txt \
    -DCMAKE_INSTALL_PREFIX=/opt/libjpeg \
    -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_C_FLAGS="-O2 -pipe" \
    -DCMAKE_EXE_LINKER_FLAGS="-s" \
    -DCMAKE_SHARED_LINKER_FLAGS="-s" \
    -DBUILD_TESTING=OFF \
    -G "Unix Makefiles" \
    ..

make -j8

and this cross toolchain file :

set(CMAKE_SYSTEM_PROCESSOR AMD64)

# binaries
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_LINKER lld)
set(CMAKE_STRIP x86_64-w64-mingw32-strip)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)

# flags
set(CMAKE_C_FLAGS "-D__USE_MINGW_ANSI_STDIO=0")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")

set(CMAKE_C_FLAGS_DEBUG "-Og -g3 -ggdb3")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS_DEBUG}")

set(CMAKE_C_FLAGS_RELEASE "-O2 -pipe -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS_RELEASE}")

cmake output :

-- The CXX compiler identification is Clang 11.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: E:/Documents/programmes_x64/msys2/mingw64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: E:/Documents/programmes_x64/msys2/mingw64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test JPEGXL_EMSCRIPTEN
-- Performing Test JPEGXL_EMSCRIPTEN - Failed
-- CMAKE_SYSTEM_PROCESSOR is AMD64
-- Performing Test CXX_FUZZERS_SUPPORTED
-- Performing Test CXX_FUZZERS_SUPPORTED - Failed
-- Performing Test CXX_CONSTRUCTOR_ALIASES_SUPPORTED
-- Performing Test CXX_CONSTRUCTOR_ALIASES_SUPPORTED - Success
-- Found PkgConfig: E:/Documents/programmes_x64/msys2/opt/ewpi_64/bin/pkg-config.exe (found version "1.7.3")
-- Compiled IDs C:Clang, C++:Clang
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HWY_EMSCRIPTEN
-- Performing Test HWY_EMSCRIPTEN - Failed
CMake Deprecation Warning at third_party/brotli/CMakeLists.txt:5 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Performing Test BROTLI_EMSCRIPTEN
-- Performing Test BROTLI_EMSCRIPTEN - Failed
-- Compiler is not EMSCRIPTEN
-- Looking for log2
-- Looking for log2 - found
-- Performing Test CXX_WPSABI_SUPPORTED
-- Performing Test CXX_WPSABI_SUPPORTED - Success
CMake Deprecation Warning at third_party/sjpeg/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Performing Test SJPEG_HAVE_FLAG___SSE2__
-- Performing Test SJPEG_HAVE_FLAG___SSE2__ - Success
-- Performing Test SJPEG_HAVE_FLAG___ARM_NEON__
-- Performing Test SJPEG_HAVE_FLAG___ARM_NEON__ - Failed
-- Performing Test SJPEG_HAVE_FLAG___ARM_NEON__
-- Performing Test SJPEG_HAVE_FLAG___ARM_NEON__ - Failed
-- Found ZLIB: E:/Documents/programmes_x64/msys2/opt/ewpi_64/lib/libz.dll.a (found version "1.2.11")
-- Found PNG: E:/Documents/programmes_x64/msys2/opt/ewpi_64/lib/libpng.dll.a (found version "1.6.37")
-- Found JPEG: E:/Documents/programmes_x64/msys2/opt/ewpi_64/lib/libjpeg.dll.a (found version "80")
-- Found OpenGL: opengl32
-- Could NOT find GLUT (missing: GLUT_glut_LIBRARY GLUT_INCLUDE_DIR)
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Found GIF: E:/Documents/programmes_x64/msys2/opt/ewpi_64/lib/libgif.dll.a (found suitable version "5.0.5", minimum required is "5")
-- Checking for module 'OpenEXR'
--   Package 'OpenEXR', required by 'virtual:world', not found
-- Found Doxygen: E:/Documents/programmes_x64/msys2/mingw64/bin/doxygen.exe (found version "1.9.1 (d71512fdcab1b28ddd750a639f5b18f1dea92599)") found components: doxygen missing components: dot
-- Found Python: E:/Documents/programmes_x64/msys2/mingw64/bin/python3.8.exe (found version "3.8.7") found components: Interpreter
CMake Warning at CMakeLists.txt:324 (message):
  asciidoc was not found, the man pages will not be installed.

-- Building with JPEGXL_VERSION=4122f3e (auto-updated)
-- Checking for module 'libwebp'
--   Found libwebp, version 1.2.0
-- Checking for module 'libavif'
--   Found libavif, version 0.9.1
-- Configuring done
-- Generating done
-- Build files have been written to: E:/Documents/programmes_x64/msys2/home/vtorri/gitroot_64/jpeg-xl/builddir

Expected behavior

build should success...

Environment

ghost commented 3 years ago

I guess you may be able to workaround the problem by updating giflib to a newer version.

giflib 5.0.5: lib/gif_lib.h:int DGifCloseFile(GifFileType * GifFile);

giflib 5.2.1: gif_lib.h: int DGifCloseFile(GifFileType * GifFile, int *ErrorCode);

vtorri commented 3 years ago

what is wrong is your build system. If you want to require at least this version of giflib, then fix it. Indeed, the cmake output is (see above too):

-- Found GIF: E:/Documents/programmes_x64/msys2/opt/ewpi_64/lib/libgif.dll.a (found suitable version "5.0.5", minimum required is "5")

I'll update gif, thank you

vtorri commented 3 years ago

after updating giflib, all is ok, closing

But you should really check giflib version....

veluca93 commented 3 years ago

Leaving this open until we fix the CMake config :)

sboukortt commented 3 years ago

Our apologies for the inconvenience. We simply weren’t aware that it didn’t work in 5.0. We haven’t tested such old versions — 5.1 is enough and that was released in 2014, four years before the version of CMake that we require.