cannot compile 4.6.x on ubuntu 24.04

While I compiled correctly darktable in ubuntu 22.04 with

./build.sh --prefix /opt/darktable/ --build-type Release && sudo git config --global --add safe.directory /home/paolo/git/darktable && sudo cmake --build "/home/paolo/git/darktable/build" --target install -- -j12

after upgrading to 24.04 compilation ends with the error:

[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/imageio/imageio_j2k.c.o
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/entry.c.o
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/label.c.o
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/file_chooser.c.o
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/section_label.c.o
gmake[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libgmic.so', needed by 'bin/libdarktable.so'.  Stop.
gmake[2]: *** Waiting for unfinished jobs....
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/separator.c.o
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/slider.c.o
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/stack.c.o
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/text_view.c.o
[ 36%] Building C object bin/CMakeFiles/lib_darktable.dir/lua/widget/widget.c.o
[ 37%] Building C object bin/CMakeFiles/lib_darktable.dir/common/cups_print.c.o
[ 37%] Building C object bin/CMakeFiles/lib_darktable.dir/common/printing.c.o
[ 37%] Building C object bin/CMakeFiles/lib_darktable.dir/common/printprof.c.o
/home/paolo/git/darktable/src/imageio/imageio_j2k.c:33:10: fatal error: openjpeg.h: No such file or directory
   33 | #include <openjpeg.h>
      |          ^~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [bin/CMakeFiles/lib_darktable.dir/build.make:2252: bin/CMakeFiles/lib_darktable.dir/imageio/imageio_j2k.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:2094: bin/CMakeFiles/lib_darktable.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[ 37%] Built target validate_wbpresets_json
gmake: *** [Makefile:156: all] Error 2

I have libopenjp2-7-dev installed.

What should I do?

First thing would be to check if you actually have the file the compiler is complaining about, and where it is located…
(it should be visible under /usr/include, bu well…)

did you reuse an existing working copy and not clean the build env after the upgrade?

I removed the build directory, but nothing changes

check if you actually have the file the compiler is complaining about, and where it is located…

$ locate openjpeg.h
/usr/include/openjpeg-2.5/openjpeg.h

hmmm… libopenjp2-7-dev installs openjpeg.h in openjpeg-2.5 directory???

… or your locate DB isn’t up-to-date. :wink:

Try this:

$ dpkg -L libopenjp2-7-dev

HTH,
Flössie

It seems ok

$ dpkg -L libopenjp2-7-dev
/.
/usr
/usr/include
/usr/include/openjpeg-2.5
/usr/include/openjpeg-2.5/openjpeg.h
/usr/include/openjpeg-2.5/opj_config.h
/usr/include/openjpeg-2.5/opj_stdint.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libopenjp2.a
/usr/lib/x86_64-linux-gnu/libopenjpip_server.a
/usr/lib/x86_64-linux-gnu/openjpeg-2.5
/usr/lib/x86_64-linux-gnu/openjpeg-2.5/OpenJPEGConfig.cmake
/usr/lib/x86_64-linux-gnu/openjpeg-2.5/OpenJPEGTargets-none.cmake
/usr/lib/x86_64-linux-gnu/openjpeg-2.5/OpenJPEGTargets.cmake
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libopenjp2.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/libopenjpip.pc
/usr/share
/usr/share/doc
/usr/share/doc/libopenjp2-7-dev
/usr/share/doc/libopenjp2-7-dev/copyright
/usr/share/man
/usr/share/man/man3
/usr/share/man/man3/libopenjp2.3.gz
/usr/include/openjpeg-2.1
/usr/lib/x86_64-linux-gnu/libopenjp2.so
/usr/lib/x86_64-linux-gnu/openjpeg-2.1
/usr/share/doc/libopenjp2-7-dev/changelog.Debian.gz

Yes, it is not 2.7 but libopenjpg2 with build index 7.

2 Likes

That might be it: I’m not sure whether gcc looks in subdirectories of /usr/include when hunting for #include’d files (I remember having to specify the subdirectory in a few cases)

This has nothing to do w/ GCC - CMake should take of feeding all the appropriate include paths.

Btw, why build when 4.6.1 is already in the 24.04 repo?

why build when 4.6.1 is already in the 24.04 repo?

in order to be able to build darktable when next version is released

dt’s cmake is, well.
FindOpenJPEG.cmake sets OpenJPEG_INCLUDE_DIR, never sets OpenJPEG_INCLUDE_DIRS:

but then the latter is used:

No wonder the header is not picked up.
This never came up because traditionally the header was carelessly dropped into /usr/include,
and was always picked up without extra include directories.

so something has to be modified in order to compile dt?

-    include_directories(SYSTEM ${OpenJPEG_INCLUDE_DIRS})
+    include_directories(SYSTEM ${OpenJPEG_INCLUDE_DIR})

That being said, there’s also that gmic error in your build output, so maybe i’m wrong and something else is going on?

How come it works on Debian OOTB for the dt CI? And Ubuntu deb?

Also, AFAIK, OpenJPEG ships w/ own config files so FindOPENJEG.cmake should not be relevant…

With you change, dt compiled perfectly. Thank you very much!

The only problem I note is that when exiting (ALT-F4), dt doens’t terminate, something keeps running, and must be killed with killall -9 darktable in order to run dt again. If I run dt from the terminal, nothing is shown, and ctl-c doesn’t kill it.

Actually, that happens with ubuntu package’s dt, too.

Actually, looking at libfind_process() again, it’s supposed to set OpenJPEG_INCLUDE_DIRS,
so i’m unsure as to what is going on.