Revive an old issue: Allow gmic-qt to link the shared libgmic

I will test with that. but wouldnt that mean that gmic.h should always include CImg.h?

No. Actually gmic.h includes CImg.h only when building the gmic core library.
It should not be mandatory for other targets.

namespace cimg_library {

  // Class 'gmic_image<T>'.
  template<typename T> struct gmic_image {
    unsigned int _width;       // Number of image columns (dimension along the X-axis)
    unsigned int _height;      // Number of image lines (dimension along the Y-axis)
    unsigned int _depth;       // Number of image slices (dimension along the Z-axis)
    unsigned int _spectrum;    // Number of image channels (dimension along the C-axis)
    bool _is_shared;           // Tells if the data buffer has been allocated by another object
    T *_data;                  // Pointer to the first pixel value

    // Destructor.
    ~gmic_image() {
      if (!_is_shared) delete[] _data;
    }

so the compiler hint is correct and the gmic-qt code should use ->_width ?

I think the problem is that G’MIC-Qt should theoretically use the gmic_image<T> structures rather than the CImg<T> (they are basically the same binary structure, but CImg<T> has a lot of methods).
As gmic_build is set, G’MIC-Qt assumes that the CImg structures are available.
But if we want to disable gmic_build, G’MIC-Qt should still build, and in that case it probably requires an explicit include of “CImg.h”

Please move this line out of the #ifdef gmic_build

// Define some special character codes used for replacement in double quoted strings.
const char gmic_dollar = 23, gmic_lbrace = 24, gmic_rbrace = 25, gmic_comma = 26, gmic_dquote = 28,
  gmic_store = 29; // <- this one is only used in variable names.

why that ? is it used by g’mic-qt ?

yes.

Another suggestion : we could keep gmic_build set and just disable the cimg_plugin and cimglist_plugin if they are already defined.

So you would just have to define them to empty strings.

This means doing that in gmic.h, around l.198

#ifndef cimg_plugin
#define cimg_plugin "gmic.cpp"
#endif
#ifndef cimglist_plugin
#define cimglist_plugin "gmic.cpp"
#endif

patching gmic done:

1 Like

I am curious … if we port gmic-qt from CImg<T> to gmic_image<T> would we still need CImg.h in the devel package?

That’s a good question indeed, and I cannot say (I’m not the author of the plug-in code).
Maybe G’MIC-Qt uses some of the features of CImg, maybe not.
I’ll ask Sébastien about that.

btw: with my 2 patches above + https://github.com/cryptomilk/gmic-qt/commits/asn-cmake

it should be possible to ship gmic and gmic-qt separately.

1 Like

would you also accept the part that will install CImg.h for now?

and while you are touching git. could it be you didnt push the tag?

Almost there…

/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/Host/KritaPlugin/host.cpp: In function 'void GmicQtHost::getCroppedImages(cimg_library::CImgList<float>&, cimg_library::CImgList<char>&, double, double, double, double, GmicQt::InputMode)':
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/Host/KritaPlugin/host.cpp:110:23: error: 'string' is not a member of 'cimg_library::CImg<char>'
  110 |     gmic_image<char>::string(ba.constData()).move_to(imageNames[i]);
      |                       ^~~~~~
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/Host/KritaPlugin/host.cpp:126:12: error: 'struct cimg_library::CImg<float>' has no member named 'move_to'
  126 |       gimg.move_to(images[i]);
      |            ^~~~~~~
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/Host/KritaPlugin/host.cpp: In function 'void GmicQtHost::outputImages(cimg_library::CImgList<float>&, const cimg_library::CImgList<char>&, GmicQt::OutputMode)':
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/Host/KritaPlugin/host.cpp:151:31: error: 'struct cimg_library::CImgList<float>' has no member named 'size'
  151 |   for (uint i = 0; i < images.size(); ++i) {
      |                               ^~~~
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/Host/KritaPlugin/host.cpp:154:37: error: 'struct cimg_library::CImgList<float>' has no member named 'at'
  154 |     gmic_image<float> gimg = images.at(i);
      |                                     ^~

pinging the krita team as well

You mean, in the CMakeList file ?

I can’t. I’m not the owner of the gmic-qt plugin. He is actually away for a while (still a few days I think).

Those supposed missing declarations are actually well-known member functions of the CImg<T> class.

missing include for CImg.h. I fixed plain qmic-qt but not the krita part yet.

yes