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

Original issue: https://github.com/c-koi/gmic-qt/pull/81

It mentions a problem with the gmic headers which needs to be sorted out first. (the issue link is sadly 404 now)

so my question is … can this be solved? that would allow the other out of tree plugins to build more nicely as well.

My error - not Gimp issue

@David_Tschumperle any thoughts on this issue?

If you build libgmic as a shared library and have gmic.h installed in the system. It still has two definitions:

#define cimg_plugin “gmic.cpp”
#define cimglist_plugin “gmic.cpp”

Couldn’t the cimg_plugin code in gmic.cpp split out into a plugin header file?

WIP: https://github.com/cryptomilk/gmic-qt/commits/asn-cmake

Hi @David_Tschumperle

any thoughts on this issue? we would be happy to help fixing this, but some guidance of what would be your preferred solution, would be awesome.

I’m super busy until at least next tuesday, too much to think about this kind of problems :slight_smile:
But I’ll try to look at this with a clear head at the end of next week.

(I’m in the process of applying for a career advancement, and it’s taking a lot of effort to write my application).

2 Likes

OK, so after looking at the file gmic_qt.pro , there already is an option to compile gmic_qt so that it depends on the libgmic.so file.

qmake GMIC_DYNAMIC_LINKING=on

I’m testing right now to see what happens :slight_smile:

PS That works.

sure … but we still need to solve that your gmic headers have an include on gmic.cpp :slight_smile:

what would be your preferred solution for this?

I don’t see this as a problem to be honest. The fact is that this does not prevent gmic-qt to be linked with a shared libgmic, as I will do for next G’MIC release 3.0.1 (planned tomorrow).
By the way, I’m not using the CMakeFile way, but the provided Makefile in src/.
Don’t ask me how to do it with cmake, I don’t know :slight_smile:

well the include “gmic.cpp” means that code is basically compiled twice. (once for libgmic once into gmic-qt) so if it ends up in the object file then it might almost not be needed to link libgmic.

Not at all.
As I said, gmic-qt is now able to use libgmic if GMIC_DYNAMIC_LINKING=on.

well then i will try to split out the patched gmic-qt for krita 5 and use the system libgmic.

I jut thought of this Re: [PATCH 0000/2297] [ANNOUNCE, RFC] "Fast Kernel Headers" Tree -v1: Eliminate the Linux kernel's "Dependency Hell" - Ingo Molnar … which had a “minor” speed up from cleaning up headers :slight_smile:

looking forward to 3.0.1

Ok testing done

  1. package updated to 3.0.1.
  2. patched cmake to also install CImg.h into libgmic-devel
  3. try to build the krita’s version gmic-qt against the sytem copy of gmic

fails with

In file included from /home/abuild/rpmbuild/BUILD/krita-5.0.2/3rdparty/gmic-qt/src/FilterSelector/FiltersModelReader.cpp:41:
/usr/include/gmic.h:194:21: fatal error: gmic.cpp: No such file or directory
  194 | #define cimg_plugin "gmic.cpp"

so I would need to ship the gmic.cpp file in the devel package. which feels wrong.

A post was split to a new topic: Gimp plugin building

@darix

Bonjour,

The problem you have posed is predominantly solved with the December 13 version that uses libgmic.so.301

libggmic.so.301 is compiled once which corresponds to the request.

There are still some details to correct but not (or very little) for the QT version.

:o)

I have time today to discuss about that.
A few notes :

  • The ‘Krita’ target fror G’MIC is not needed anymore, as Krita 5 now ships the G’MIC plug-in by default. The krita target from the G’MIC source is then now deprecated, and only useful for Krita 4. It will be probably removed in a few versions.

  • The macro cimg_plugin used in gmic.cpp should be only defined when you compile libgmic, but none of its interface.

  • If you really need cimg_plugin to be defined for something else than building libgmic (but honestly, that’s weird :slight_smile: ), then note that the value of cimg_plugin must be a path to the gmic.cpp file, relative to the path of CImg.h. In the original G’MIC sources, CImg.h and gmic.cpp are located in the same folder, that’s why the value of cimg_plugin is just "gmic.cpp". You can also let this value as it is and set the -I/path_to_gmic_cpp_folder/ flag when compiling.

1 Like

I am very well aware that krita now has a patched copy gmic-qt.

This is actually what I am trying to get build against the system libgmic.

so the problem is that gmic-qt defines gmic_build (in cmake and in the QT build system)?

I would rather fix the flaws in the build system so I avoid feeding gmic.pp N times into the compiler :smiley:

Testing now. will report back.

Ok I patched out the define now:

/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp: In static member function 'static void GmicQt::CroppedImageListProxy::update(double, double, double, double, GmicQt::InputMode, double)':
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp:65:52: error: 'struct cimg_library::CImgList<float>' has no member named 'size'
   65 |     for (unsigned int i = 0; i < _cachedImageList->size(); ++i) {
      |                                                    ^~~~
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp:67:13: error: 'struct cimg_library::CImg<float>' has no member named 'resize'
   67 |       image.resize(std::round(image.width() * zoom), std::round(image.height() * zoom), 1, -100, 1);
      |             ^~~~~~
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp:67:37: error: 'struct cimg_library::CImg<float>' has no member named 'width'; did you mean '_width'?
   67 |       image.resize(std::round(image.width() * zoom), std::round(image.height() * zoom), 1, -100, 1);
      |                                     ^~~~~
      |                                     _width
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp:67:71: error: 'struct cimg_library::CImg<float>' has no member named 'height'; did you mean '_height'?
   67 |       image.resize(std::round(image.width() * zoom), std::round(image.height() * zoom), 1, -100, 1);
      |                                                                       ^~~~~~
      |                                                                       _height
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp: In static member function 'static void GmicQt::CroppedImageListProxy::clear()':
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp:74:27: error: no matching function for call to 'cimg_library::CImgList<float>::assign()'
   74 |   _cachedImageList->assign();
      |   ~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp:31:
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/src/gmic.h:151:19: note: candidate: 'cimg_library::CImgList<T>& cimg_library::CImgList<T>::assign(unsigned int) [with T = float]'
  151 |     gmic_list<T>& assign(const unsigned int n);
      |                   ^~~~~~
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/src/gmic.h:151:19: note:   candidate expects 1 argument, 0 provided
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp:75:28: error: no matching function for call to 'cimg_library::CImgList<char>::assign()'
   75 |   _cachedImageNames->assign();
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /home/abuild/rpmbuild/BUILD/gmic-3.0.1/gmic-qt/src/CroppedImageListProxy.cpp:31:
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/src/gmic.h:151:19: note: candidate: 'cimg_library::CImgList<T>& cimg_library::CImgList<T>::assign(unsigned int) [with T = char]'
  151 |     gmic_list<T>& assign(const unsigned int n);
      |                   ^~~~~~
/home/abuild/rpmbuild/BUILD/gmic-3.0.1/src/gmic.h:151:19: note:   candidate expects 1 argument, 0 provided

OK, but be aware that the code of the Krita 5 G’MIC plug-in is not available in the G’MIC source code, but only in the Krita repository. We only have the version for Krita 4.

Maybe yes, if you plan to build G’MIC-Qt from the libgmic.so file, then gmic_build is probably not needed.

Right. gmic.cpp should be not needed to build gmic-qt if you want to use a dependency to the shared libgmic.so

In that case, that means “CImg.h” is not included anymore by G’MIC-Qt when gmic_build is undefined.
You may try to include it before gmic.h to fix the thing.