Bug 426284

Summary: Cannot build digikam using Craft on Windows 10. "ninja: error: 'opencv_imgcodecs-NOTFOUND'"
Product: [Applications] digikam Reporter: mrbus
Component: Portability-RuntimeAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles
Priority: NOR    
Version First Reported In: 7.1.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In: 7.5.0
Sentry Crash Report:
Attachments: build log

Description mrbus 2020-09-07 18:53:06 UTC
SUMMARY
I'm trying to build digikam with Craft build system on Windows 10.
I tried to build it with different settings of Craft (CraftRoot/etc/CraftSettings.ini).
With `UseNinja = True` I receive "ninja: error: 'opencv_imgcodecs-NOTFOUND', needed by 'core/app/digikamgui_autogen/timestamp', missing and no known rule to make it".
But the output above shows that,
"-- Found OpenCV: C:/C (found version "4.3.0") found components: core objdetect imgproc imgcodecs dnn flann 
-- OpenCV Root directory is: C:/C/lib/cmake/opencv4
-- OpenCV: Found version 4.3.0 (required: 3.3.0)
-- OpenCV headers: C:/C/include/opencv4
-- OpenCV libs   : opencv_core;opencv_objdetect;opencv_imgproc;opencv_imgcodecs;opencv_dnn;opencv_flann"

With `UseNinja = False` and `MakeProgram = jom` I receive:
"C:\_\d9b0fe74\build\core\app\utils\digikam_opencv.h(79): fatal error C1083: Cannot open include file: opencv2/ml.hpp: No such file or directory,
C:\_\4e371c3b\digikam\core\libs\jpegutils\jpegutils.cpp(46): fatal error C1083: Cannot open include file: jpeglib.h: No such file or directory,"
With `UseNinja = False` and `MakeProgram = nmake` output is similar.

STEPS TO REPRODUCE
1. Install Craft system to "C:\C" (do not install to default directory C:\CraftRoot, otherwise you will receive errors related to command line length limitation on Windows, see https://bugs.kde.org/show_bug.cgi?id=426264).
2. In C:\C\etc\CraftSettings.ini, set `JunctionDir=C:\_` otherwise you will face the same issue again.
3. Execute "craft digikam >output.txt".

OBSERVED RESULT
digikam build fails


EXPECTED RESULT
digikam build succeeds


SOFTWARE/OS VERSIONS
Windows: 10
Comment 1 caulier.gilles 2020-09-08 07:35:40 UTC
"C:\_\d9b0fe74\build\core\app\utils\digikam_opencv.h(79): fatal error C1083: Cannot open include file: opencv2/ml.hpp: No such file or directory,

==> this error is due to missing Machine Learning opencv module.
The OpenCV installed by Craft is incomplete.

C:\_\4e371c3b\digikam\core\libs\jpegutils\jpegutils.cpp(46): fatal error C1083: Cannot open include file: jpeglib.h: No such file or directory,

==> libjpeg header are not installed by Craft or are not shared properly.

To resume, report this problem to Craft team. There is nothing to do in digiKam source code. We already compile whole digiKam for Windows using MSVC or Mingw without problem...

Best

Gilles Caulier
Comment 2 mrbus 2020-09-12 01:16:08 UTC
Thank you.
How do you build digikam for Windows? Without Craft, or with Craft, anyway.
I also tried cross compilation using MXE and it did not work too, because MXE missing some KF5 libs.
Comment 3 caulier.gilles 2020-09-12 04:03:25 UTC
Hi,

We use MXE since a while. We never use Craft, as it's too complicated and share too much configuration with plenty of different applications.

All the CI from KDE build server has compilation/configuration problem (as MinGW, MacOS, Windows MSVC, etc...)

The KF5 availability on MXE is not a problem. All build fine. I write bash/CMake scripts to cross-compile and build the Windows installer from scratch under Linux. Take a look here :

https://invent.kde.org/graphics/digikam/-/tree/master/project/bundles/mxe

Gilles Caulier
Comment 4 mrbus 2020-09-12 19:51:46 UTC
(In reply to caulier.gilles from comment #3)
> Take a look here :
> 
> https://invent.kde.org/graphics/digikam/-/tree/master/project/bundles/mxe
> 
> Gilles Caulier

Thank you. But 01-build-mxe.sh fails:
"Failed to build package mesa for target x86_64-w64-mingw32.shared!
    from mako.template import Template
ImportError: No module named mako.template"

I guess this error is related to Python, but I checked the mako module, it is installed:
"pip3 install mako --upgrade"
also
"sudo pip3 install mako --upgrade"
but the error remains.

(Previously, I built MXE manually and it has built successfully).
Comment 5 caulier.gilles 2020-09-12 20:01:30 UTC
yes i can reproduce here.

this have been reported as upstream to mxe

https://github.com/mxe/mxe/issues/2561

Gilles Caulier
Comment 6 mrbus 2020-09-12 20:45:10 UTC
That was my fault.
MXE uses Python2 but I ran pip3.
Fixed.
Excuse for troubling.
Comment 7 mrbus 2020-09-15 02:44:00 UTC
Created attachment 131665 [details]
build log
Comment 8 mrbus 2020-09-15 02:51:19 UTC
(In reply to caulier.gilles from comment #1)
> "C:\_\d9b0fe74\build\core\app\utils\digikam_opencv.h(79): fatal error C1083:
> Cannot open include file: opencv2/ml.hpp: No such file or directory,
> 
> ==> this error is due to missing Machine Learning opencv module.
> The OpenCV installed by Craft is incomplete.

When using MXE, I receive the same error (see attachment).
Line 223:
/root/dktemp/digikam-master/build.mxe/core/app/utils/digikam_opencv.h:79:10: fatal error: opencv2/ml.hpp: No such file or directory
   79 | #include "opencv2/ml.hpp"
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Comment 9 caulier.gilles 2020-09-15 02:52:20 UTC
This is the Machine Learning include which is missing. I upgraded openc from 3 to 4. i will take a look.

Gilles Caulier
Comment 10 mrbus 2020-09-15 03:03:20 UTC
Thank you.
Maybe this information will be useful.
Previously, when used Craft, I tried this workaround:
1. Manually install opencv from sourceforge.net
2. Copy ml.hpp and ml subdirectory to Craft's include directory
3. Change core\app\utils\digikam_opencv.h.cmake.in line 79 from
#include "opencv/ml.hpp"
to
#include <opencv/ml.hpp>
and it helped, but then I receive link-time error, "cannot open file opencv_ml.lib", and this file doesn't really exist.
Comment 11 caulier.gilles 2020-09-15 20:00:40 UTC
[100%] Performing install step for 'ext_mosaicwall'
make[4]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /mnt/data/GIT/7.x/project/bundles/mxe/build.win32/usr/i686-w64-mingw32.shared/bin/ImageMosaicWall.exe
-- Installing: /mnt/data/GIT/7.x/project/bundles/mxe/build.win32/usr/i686-w64-mingw32.shared/lib/plugins/digikam/generic/Generic_ImageMosaicWall_Plugin.dll
[100%] Completed 'ext_mosaicwall'
[100%] Built target ext_mosaicwall
Elaspsed time for script execution : 1 hours 40 minutes 55 seconds

[gilles@localhost mxe (master)]$ 


^^^^ All digiKam compile fine with MXE.

You don't need to install an extra OPenCV version. OpenCV is compiled with the MXE build script. There is a rule with cmake to get the OpenCV source code 4.4 and to compile and install the library in MXE build env.

https://invent.kde.org/graphics/digikam/-/blob/master/project/bundles/mxe/01-build-mxe.sh#L184

https://invent.kde.org/graphics/digikam/-/blob/master/project/bundles/3rdparty/ext_opencv/CMakeLists.txt

So clean up and try again to restart MXE build.

Gilles Caulier
Comment 12 mrbus 2020-09-19 07:18:01 UTC
02-build-extralibs.sh line 122: "cmake . \"
Did you mean: "${MXE_BUILD_TARGETS}-cmake . \" ?

I tried to build from scratch on absolutely clean Debian. I got a "command not found" error (don't remember the exact text). Then, after installed "sudo apt install cmake" I got errors related to qt5, and after "sudo apt-get install qt5-default" I get errors again
Comment 13 caulier.gilles 2020-09-19 07:22:47 UTC
Hi,

Typically no, because it's to build PNGICO program for native host OS,not for the cross-compiled MXE target. Look well the comment at line 116.

Gilles Caulier
Comment 14 caulier.gilles 2022-01-08 16:24:32 UTC
MrBus,

Any fresh feedback from this thread ?

Best

Gilles Caulier
Comment 15 mrbus 2022-01-08 17:03:21 UTC
(In reply to caulier.gilles from comment #14)
> MrBus,
> 
> Any fresh feedback from this thread ?
> 
> Best
> 
> Gilles Caulier

Thank you. Eventually, I built it somehow. I don't remember, a lot of time has passed. I think the bug can be closed because it is no longer relevant.