Some Gtkmm/Cairomm functions cannot be linked

I did not find any answer online yet so I am asking here:
I am using Win10+msys2+CodeBlocks for Gtkmm applications. Everything is working so far but I found 2 things having linking problems: Gtk::Image, Cairo::select_font_face and some other Cairo font related functions. I can do cr->move_to, cr->line_to etc.

For example the function “cr->select_font_face (“Purisa”, Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD);” can compile but I get this linker error: “undefined symbol … error: ld returned 1 exis status.”.

What could be wrong? Other Cairo functions work and I believe all come from the same library. Do I miss something?

…and sorry, if this topic does not belong to here…
Jozef

I don’t use CodeBlocks myself, basically you have to use the msys2 toolchain/compiler and select the libraries to use. gtkmm-3.0 should be enough.

You can try compiling from the MSYS2 MINGW64 shell:

gcc -o executable.exe source1.cpp source2.cpp sourcen.cpp `pkg-config --cflags --libs gtkmm-3.0`

That way you can determine if the problem is just about the CodeBlocks configuration

This link may help: GTK+ via MSYS2 with CodeBlocks - Stack Overflow

Thank you, lb90.
This is exactly what I did. It seems that the linker does not really use pkg-config --libs gtkmm-3.0, I had to include the libraries on my own. I was wondering, why only some Gtk & Cairo components are not working, like Gtk::Image and the texting option of Cairo…
How could I find out, which library to include instead of including everything? Why does e.g. cairo::line_to() work and cairo::show_text() don’t? Aren’t they in the same library?

Yes, I agree that it’s strange. You should replicate in CodeBlocks all that you get from running pkg-config --cflags --libs gtkmm-3.0 in the MSYS2 MINGW shell

It could be a linker issue on Windows. GTK definitely uses cairo_line_to(), but it most definitely doesn’t use cairo_show_text(). The symbols used by GTK may be “leaking” in the address space of your project, which means that the linker already knows how to resolve them, whereas the symbols not used by GTK need an explicit dependency.

Thank you very much, guys, for your help.

2 Likes

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