Tests are failing when compiling GIMP with added (dock) feature

Hello, I’m trying to add some animation capabilities to GIMP, and I started it by adding a new dock (commit for reference: app/dialogs: add animation dock and window · nazsombor/gimp-animation@f8613f8 · GitHub) I followed the way as other docks are added:

  1. added a DOCK and DOCK_WINDOW to entries[] in app/dialogs/dialogs.c
  2. added the corresponding functions in app/dialogs/dialogs-constructors.c
  3. created gimpanimation.c to implement gimp_animation_new() GtkWidget* (for now I only copied gimptoolbox.c to have a minimally changed file, until I discover all the functionalities I may need)
  4. added the #include header gimpanimation.h to dialogs-constructors.c and to gimpanimation.c

I know there must be more to do to show a dock, but when I try to build this, the tests are failing due to undefined reference:

[15/17] Linking target app/tests/ui
FAILED: app/tests/ui 
c++  -o app/tests/...
...
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.1.0/../../../../x86_64-unknown-linux-gnu/bin/ld: app/dialogs/libappdialogs.a.p/dialogs-constructors.c.o: in function `dialogs_animation_new':
/home/user/Projects/gimp-animation/_build/../app/dialogs/dialogs-constructors.c:342: undefined reference to `gimp_animation_new'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

I looked around but I could not find anything that could cause this. I’m a beginner in C programming though.

Any help is much appreciated

You need to add your new gimpanimations.c file to the buildsystem so it knows about it and can compile it together with the rest of the existing files. In your case, you’ll probably have to explicitly add the file to the list of source files in app/dialogs/meson.build

That is what I missed, thank you so much!

One more issue.

Still it doesn’t build, it says:

/home/user/Projects/gimp-animation/_build/../app/widgets/gimpanimation.c:93: undefined reference to `gimp_animation_get_type'

Indeed, gimp_animation_get_type(void) is only defined in gimpanimation.h which is not added to meson.build, but this is the same as with gimp_toolbox_get_type(void), only defined in gimptoolbox.h and not added to build scripts.

Maybe add a line to widget-types.h ?

I recall having this problem, but can’t remember the answer.

You might grep for “GimpToolbox” and similar, or the name of the thing whose source you have cloned,
to see everywhere it is mentioned.

I think foo_get_type is defined by the macro that declares a the type, G_DEFINE_TYPE_WITH_PRIVATE.
Maybe look at the expanded macro, there is a way to do that.

GObject and it’s macros can be very obscure.

Thank you for your help!

I added the necessary line to widget-types.h, it was missing before. I also grep-ed but haven’t found anything yet. I will update here as soon as I pass this error.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.