![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
Corrected against fa8e8b86fa on 2026-09-29. The audit before that found 4 claim(s) in this file wrong of the tree and 7 stale. Mostly right; the option table was presented as deviations when most rows are upstream defaults, and the NLS workaround needed the function-vs-macro warning its neighbour already carries. Re-measure before acting on a claim older than the code you are changing, and re-date this line when you do.
Ansel builds its own Exiv2, from the src/external/exiv2 submodule, pinned at v0.27.7 and linked statically into lib_ansel. This is the default on every platform.
-DUSE_BUNDLED_EXIV2=OFF links whatever the system provides instead, for packagers who need it. It is supported, but it is not the tested configuration, and it comes with one hard requirement (ISOBMFF, below) that several distributions do not meet.
Exiv2 is not an ordinary dependency. Ansel does not merely link it, it inherits its behaviour:
Leaving both of those to three packagers produced three different products, and that is what issue #474 turned out to be:
Upstream darktable has the same problem and answers it the same way: their Windows nightly builds Exiv2 v0.27.7 from source with -DEXIV2_ENABLE_WIN_UNICODE=ON, while their Linux AppImage builds v0.28.8. Their one attempt at a code-level fix (PR #15899, "switch Windows to UTF-8 locale entirely", 34 files) was auto-closed unmerged after 300 days.
In src/external/CMakeLists.txt. Most of the table is Exiv2 0.27.7's own default and is listed to say we checked, not to say we changed it — src/external/exiv2/CMakeLists.txt:18-36 already ships XMP ON, PNG ON, NLS OFF, LENSDATA ON, VIDEO/WEBREADY/CURL/SSH OFF and UNIT_TESTS/FUZZ_TESTS/DOC OFF. The genuinely non-default rows are BUILD_SHARED_LIBS=OFF, EXIV2_ENABLE_BMFF=ON, EXIV2_ENABLE_WIN_UNICODE=ON and EXIV2_BUILD_SAMPLES/_EXIV2_COMMAND=OFF. Setting a default explicitly is still worth doing here — a submodule bump can change one — but do not read the table as a list of deviations.
| Option | Value | Why |
|---|---|---|
| BUILD_SHARED_LIBS | OFF | Static: nothing else in the process can supply a second libexiv2, and there is no extra shared object to ship. |
| EXIV2_ENABLE_BMFF | ON | CR3, AVIF, HEIF. Required — see below. Exiv2 0.27's default is OFF. |
| EXIV2_ENABLE_XMP | ON | The whole XMP sidecar layer. Pulls in expat. |
| EXIV2_ENABLE_PNG | ON | PNG metadata. Pulls in zlib. |
| EXIV2_ENABLE_LENSDATA | ON | Nikon lens tables. |
| EXIV2_ENABLE_WIN_UNICODE | ON on Windows | Defines EXV_UNICODE_PATH, the wide-path API. Without it, non-ASCII paths do not open. |
| EXIV2_ENABLE_NLS | OFF | See Native language support below. |
| EXIV2_ENABLE_VIDEO, _WEBREADY, _CURL, _SSH | OFF | Ansel reads metadata from files, never over the network. Keeps libcurl and libssh out of Exiv2's link line. |
| EXIV2_BUILD_SAMPLES, _EXIV2_COMMAND, _UNIT_TESTS, _FUZZ_TESTS, _DOC | OFF | We want the library, not the distribution. |
Build dependencies this leaves us with: expat (the bundled XMP SDK) and zlib (PNG). Iconv is used when present. The packaging/install-deps-*.sh scripts install expat explicitly (install-deps-suse.sh:70,164, install-deps-macos.sh:36, packaging/nix/default.nix:13) and not zlib, which they leave to whatever already pulls it in — every one of these platforms has it through another dependency. That works, and it is worth knowing it is implicit rather than stated, because a platform that ever lacks it fails at link time with no clue pointing here.
src/CMakeLists.txt probes the EXV_ENABLE_BMFF symbol in the Exiv2 we are actually linking and fails the configure if it is absent. There is no HAVE_LIBEXIV2_WITH_ISOBMFF macro any more, and no degraded build: cr3 is unconditionally in DT_SUPPORTED_EXTENSIONS, and dt_exif_init() calls Exiv2::enableBMFF() unconditionally on 0.27.x.
The reason is what a degraded build looks like from the user's chair. Some distributions — Fedora among them — still build Exiv2 with EXIV2_ENABLE_BMFF=OFF over long-settled patent worries. Canon CR3 is among the most common file types in Ansel's telemetry. An Ansel linked against such a build starts perfectly well and then cannot open the user's raws, and nobody reading that screen concludes that their distribution disabled a flag in a metadata library: they file a bug against Ansel. A configure-time error costs a packager five minutes. The alternative costs every one of their users their raw files, and costs us the bug report.
If you hit that error with -DUSE_BUNDLED_EXIV2=OFF, the fix is either to rebuild Exiv2 with -DEXIV2_ENABLE_BMFF=ON or — far easier — to drop back to the bundled build.
Every path inside Ansel is UTF-8: that is what GLib hands us, what the database stores, and what the film-roll scanner produces. On Windows the narrow CRT reads a const char * path in the process ANSI code page instead — CP-1252, CP-850, whatever the machine is set to — so a path holding a single byte above 0x7F simply does not resolve.
Ansel's answer everywhere is to widen at the library boundary: libraw_open_wfile() in imageio/imageio_libraw.c, TIFFOpenW() in imageio/imageio_tiff.c, g_fopen() (which is _wfopen() underneath) in the XMP sidecar writer. Exiv2 is the same case, and WIDEN() in metadata/exif_internal.h is where it happens.
Three things there are deliberate:
tools/check_it_runs.sh and the Windows job in .github/workflows/ci.yml both export from a path named Épreuve — тест and fail on Failed to open the data source. Every round of #474 — 2023, 2025, twice in 2026 — was found months later by a user with a screenshot. That check is what would have caught each one the day it landed; do not remove it.
EXIV2_ENABLE_NLS=OFF, and it is not simply a matter of flipping the flag.
Exiv2's po/CMakeLists.txt calls CMake's GETTEXT_CREATE_TRANSLATIONS(), which runs msgmerge --update against the .po files in the source tree. In a submodule that means every build leaves src/external/exiv2 dirty.
What it costs us: Exiv2::Metadatum::print() returns some tag values from translated tables ("Manual", "Auto", …), and those show in the metadata panel. Tag names are unaffected — dt_exif_set_exiv2_taglist() reads them straight from Exiv2::ExifTags::groupList() and never goes through gettext.
To get it back, shadow GETTEXT_CREATE_TRANSLATIONS() with a version that runs msgfmt and skips the merge, before add_subdirectory(exiv2) (src/external/CMakeLists.txt:318). That is about fifteen lines and it has to keep the .mo files installing into ${CMAKE_INSTALL_LOCALEDIR}, because Exiv2 resolves EXV_LOCALEDIR relative to the running binary — which, statically linked, is ansel itself.
Write that shadow as a function, never a macro, for the reason the install() shadow twenty lines above it already documents at length (:296-310): overriding a command this way is global for the rest of the configure, and in a macro ${ARGV} is textual substitution, so every ${...} in a string argument is expanded a second time and every backslash escape eaten once more. That is not hypothetical — it shipped. The macro form reduced the Windows installer's install(CODE) DLL-collection block to a script with empty variables and an unescaped regex; it copied nothing, the .exe went from 144 MB to 118 MB, and users got an application missing libcurl, libheif, libopenexr and exchndl.dll (fixed in ed17d7db7d).
Note also that dt_strlcpy_to_utf8() in metadata/exif.cc runs print()'s output through g_locale_to_utf8(), which is inherited from darktable and is wrong for anything gettext returns (gettext gives UTF-8; the locale on Windows generally is not). Turning NLS on without looking at that first would trade one mojibake for another.
Do not, until the wide-path API is back in a release. The pin is at 0.27.7 for exactly one reason: Exiv2 commit 7933ff40, shipped in 0.28.0 (May 2023), deleted the std::wstring overloads and the EXIV2_ENABLE_WIN_UNICODE option.
The state of that, as of this writing:
So the condition for the bump is: **#3117, or an equivalent, present in a tagged Exiv2 release.** Check include/exiv2/basicio.hpp in the tag for FileIo(const std::wstring&).
When that day comes:
Embedding Exiv2 0.27.7 as a subdirectory needs a handful of things it does not do for itself, each commented at the site:
Its mainSetup.cmake also sets CMAKE_VISIBILITY_INLINES_HIDDEN, and under GCC 16 that stops the build — src/external/CMakeLists.txt turns it back off on exiv2lib, exiv2lib_int and exiv2-xmp. (Measured 2026-10-17 against 96a9bd1299, GCC 16.2.1, Fedora 44.) The link of libansel.so dies with eight copies of
which is std::string's move constructor. libstdc++ declares extern template class basic_string<char> (bits/basic_string.tcc, guarded on __cplusplus <= 202002L, so live for Exiv2's -std=gnu++17), which suppresses emission of the member in every translation unit that uses it: the definition is meant to come from libstdc++.so, which does export it with default visibility. -fvisibility-inlines-hidden then marks the reference hidden, and a hidden reference cannot bind to a shared library.
Two things about this were not obvious and cost the time:
Turning the flag off costs nothing measurable: Exiv2 is a static archive inside libansel.so, CMAKE_CXX_VISIBILITY_PRESET=hidden still covers everything that is not an inline, and LTO internalises the rest. The resulting libansel.so exports 6738 dynamic symbols, of which three are Exiv2's and one is std::'s.