ChatGPT:
The root cause of the failure is in the libjxl component’s C++ build: its APNG decoder (apng.cc) is picking up the system (Mono-framework) png.h instead of the static libpng you just built, and the API signatures have changed, so you get “no matching function” errors.
⸻
What went wrong
1. CXXFLAGS isn’t set
Your script exports
CFLAGS="-I$HOME/ffmpeg-build/workspace/include …"
CXXFLAGS=""
so C compilations see your workspace include tree (and pick up your libpng 1.6 headers), but C++ compilations do not — they fall back to /Library/Frameworks/Mono.framework/Headers/png.h (and friends), where the signatures for
png_set_keep_unknown_chunks(png_structp, int, png_bytep, int)
png_get_iCCP(png_const_structp, png_const_infop, png_charpp, …)
no longer match what apng.cc is calling.
Even if you had the right headers, the libjxl version you’re building expects an older libpng API. In particular it wants to pass a const unsigned char* to a function that now takes a mutable png_bytep, and it passes an unsigned char** where libpng wants a char**.
⸻
Two ways to fix it
- Make your workspace headers visible to C++
Before building libjxl, export your include directory into CXXFLAGS (so that -I…/workspace/include comes first):
export CXXFLAGS="-I$HOME/ffmpeg-build/workspace/include"
(you can also carry over whatever flags you need, e.g. -Wno-int-conversion)
cd ffmpeg-build/packages/libjxl-0.11.1
./deps.sh
cmake
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_C_FLAGS="$CFLAGS"
-DCMAKE_CXX_FLAGS="$CXXFLAGS"
-DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg-build/workspace"
-DCMAKE_INSTALL_LIBDIR=lib
-DCONFIG_RUNTIME_CPU_DETECT=0
.
make -j8
make install
If you’re driving everything from your top-level script, just insert:
export CXXFLAGS="$CFLAGS"
immediately before the libjxl cmake invocation.
⸻
- Patch apng.cc for the new libpng API
If for some reason you can’t change your include paths, you can locally adjust the calls in lib/extras/dec/apng.cc:
--- a/lib/extras/dec/apng.cc
+++ b/lib/extras/dec/apng.cc
@@ -578,7 +578,7 @@
- png_set_keep_unknown_chunks(png_ptr, 1, kIgnoredChunks.data(),
- png_set_keep_unknown_chunks(png_ptr, 1,
-
const_cast<png_bytep>(kIgnoredChunks.data()),
(int)kIgnoredChunks.size());
@@ -1094,7 +1094,7 @@
-
png_get_iCCP(ctx.png_ptr, ctx.info_ptr, &name, &compression_type,
-
png_get_iCCP(ctx.png_ptr, ctx.info_ptr,
-
reinterpret_cast<png_charpp>(&name),
&compression_type,
&profile, &proflen);
That’ll satisfy the current signatures, but it’s really just a workaround for an upstream–downstream mismatch.
⸻
Summary
• Why it failed: C++ compile saw the wrong (Mono) png.h -> API signature mismatches in apng.cc.
• Best fix: Export your workspace include into CXXFLAGS (e.g. export CXXFLAGS="$CFLAGS") so libjxl builds against the correct libpng headers.
• Alternative: Patch the libjxl source to cast away const and match the new libpng prototypes.
ChatGPT:
The root cause of the failure is in the libjxl component’s C++ build: its APNG decoder (apng.cc) is picking up the system (Mono-framework) png.h instead of the static libpng you just built, and the API signatures have changed, so you get “no matching function” errors.
⸻
What went wrong
1. CXXFLAGS isn’t set
Your script exports
CFLAGS="-I$HOME/ffmpeg-build/workspace/include …"
CXXFLAGS=""
so C compilations see your workspace include tree (and pick up your libpng 1.6 headers), but C++ compilations do not — they fall back to /Library/Frameworks/Mono.framework/Headers/png.h (and friends), where the signatures for
png_set_keep_unknown_chunks(png_structp, int, png_bytep, int)
png_get_iCCP(png_const_structp, png_const_infop, png_charpp, …)
no longer match what apng.cc is calling.
Even if you had the right headers, the libjxl version you’re building expects an older libpng API. In particular it wants to pass a const unsigned char* to a function that now takes a mutable png_bytep, and it passes an unsigned char** where libpng wants a char**.
⸻
Two ways to fix it
Before building libjxl, export your include directory into CXXFLAGS (so that -I…/workspace/include comes first):
export CXXFLAGS="-I$HOME/ffmpeg-build/workspace/include"
(you can also carry over whatever flags you need, e.g. -Wno-int-conversion)
cd ffmpeg-build/packages/libjxl-0.11.1
./deps.sh
cmake
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_C_FLAGS="$CFLAGS"
-DCMAKE_CXX_FLAGS="$CXXFLAGS"
-DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg-build/workspace"
-DCMAKE_INSTALL_LIBDIR=lib
-DCONFIG_RUNTIME_CPU_DETECT=0
.
make -j8
make install
If you’re driving everything from your top-level script, just insert:
export CXXFLAGS="$CFLAGS"
immediately before the libjxl cmake invocation.
⸻
If for some reason you can’t change your include paths, you can locally adjust the calls in lib/extras/dec/apng.cc:
--- a/lib/extras/dec/apng.cc
+++ b/lib/extras/dec/apng.cc
@@ -578,7 +578,7 @@
@@ -1094,7 +1094,7 @@
That’ll satisfy the current signatures, but it’s really just a workaround for an upstream–downstream mismatch.
⸻
Summary
• Why it failed: C++ compile saw the wrong (Mono) png.h -> API signature mismatches in apng.cc.
• Best fix: Export your workspace include into CXXFLAGS (e.g. export CXXFLAGS="$CFLAGS") so libjxl builds against the correct libpng headers.
• Alternative: Patch the libjxl source to cast away const and match the new libpng prototypes.