Duplicates in pkg-config --cflags gtkmm-3.0

Hi,

I tried building gtkmm-4.8.0 from source but it requires ‘gtk4 >= 4.7.2’ which is higher than apt package of GTK 4.6.6 on ubuntu. so, I’m trying gtkmm 3.0 on ubuntu linux.

The header dir list is really very long. I did a sort on the list and there are several duplicates, eg. cairo, gtk-3.0, harfbuzz, pango-1.0.

And should not -pthread go to --libs side?

$ pkg-config --cflags gtkmm-3.0

-I/usr/include/at-spi-2.0
-I/usr/include/at-spi2-atk/2.0
-I/usr/include/atk-1.0 
-I/usr/include/atkmm-1.6 
-I/usr/include/blkid 
-I/usr/include/cairo 
-I/usr/include/cairo 
-I/usr/include/cairo 
-I/usr/include/cairomm-1.0
-I/usr/include/dbus-1.0 
-I/usr/include/freetype2
-I/usr/include/fribidi 
-I/usr/include/gdk-pixbuf-2.0
-I/usr/include/gdkmm-3.0
-I/usr/include/gio-unix-2.0 
-I/usr/include/giomm-2.4
-I/usr/include/glib-2.0 
-I/usr/include/glibmm-2.4
-I/usr/include/gtk-3.0 
-I/usr/include/gtk-3.0
-I/usr/include/gtk-3.0/unix-print
-I/usr/include/gtkmm-3.0 
-I/usr/include/harfbuzz 
-I/usr/include/harfbuzz 
-I/usr/include/libmount 
-I/usr/include/libpng16 
-I/usr/include/pango-1.0  
-I/usr/include/pango-1.0 
-I/usr/include/pangomm-1.4
-I/usr/include/pixman-1 
-I/usr/include/sigc++-2.0
-I/usr/include/uuid 
-I/usr/include/x86_64-linux-gnu
-I/usr/lib/x86_64-linux-gnu/atkmm-1.6/include
-I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include
-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include
-I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include
-I/usr/lib/x86_64-linux-gnu/giomm-2.4/include
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include
-I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include
-I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include
-I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include
-I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include
-pthread 

I tried building gtkmm-4.8.0 from source but it requires ‘gtk4 >= 4.7.2’ which is higher than apt package of GTK 4.6.6 on ubuntu.

Ubuntu 22.10 contains gtk4 4.8.1 and gtkmm-4.0 4.8.0. If you have an older
version of Ubuntu, you can build an older version of gtkmm, e.g. 4.6.1.
If you build with Meson, it’s possible that you can build gtkmm 4.8.0 if you
let Meson build gtk4 as a subproject. It can take some time to build both
gtk4 and gtkmm-4.0 from source, though.

If you plan to use gtkmm in a new project, I recommend gtkmm4.

pkg-config collects compiler options from many .pc files. gtkmm-3.0.pc adds
-I/usr/include/gtkmm-3.0, but it also tells pkg-config that gtkmm-3.0 depends
on giomm-2.4, gtk-3.0, cairomm-1.0, pangomm-1.4, gdk-pixbuf-2.0, atkmm-1.6, gtk-unix-print-3.0 and gdkmm-3.0.
pkg-config reads those .pc files. They list other dependencies, which also add
compiler options. It’s possible that several modules list e.g. cairo as a dependency.

The pkg-config documentation of --cflags says

Flags are “compressed” so that each identical flag appears only once.

Doesn’t seem to be quite true.

Requarding -pthread, the documentation of gcc says

Define additional macros required for using the POSIX threads library. You
should use this option consistently for both compilation and linking.

When I run pkg-config --cflags --debug gtkmm-3.0, it says

adding CFLAGS_OTHER string "-pthread "

Don’t know what CFLAGS_OTHER is. It’s not an environment variable.

1 Like

Thanks Kjell,

I am on ubuntu 22.04 LTS version. I have not tried building gtk4 from
source. I do not know whether I will encounter dependency problem in
compiling it.

I ever thought -pthread is as same as -lpthread and is only applied
to linking option.

-pthread is not on pkg-config gtkmm-3.0 --libs, though

-latk-1.0
-latkmm-1.6
-lcairo
-lcairo-gobject
-lcairomm-1.0
-lgdk-3
-lgdk_pixbuf-2.0
-lgdkmm-3.0
-lgio-2.0
-lgiomm-2.4
-lglib-2.0
-lglibmm-2.4
-lgobject-2.0
-lgtk-3
-lgtkmm-3.0
-lharfbuzz
-lpango-1.0
-lpangocairo-1.0
-lpangomm-1.4
-lsigc-2.0

I do not know if pkg-config has --cppflags, --ldflags, --ldlibs.

In my Makefile, if I put pkg-config gtkmm-3.0 --libs in LDFLAGS, it
works on macOS 12.6.1 with clang 14, but does not work on ubuntu 22.04
with gcc 11.3. If I put it in LDLIBS, it works on both systems.

# build shared library with -fPIC, -shared
CXXFLAGS   = -std=c++11 -g # -O3 # -fPIC  # CXXFLAGS for .cpp
LDFLAGS  = # -L../hello # -shared
LDLIBS   = -pthread `pkg-config gtkmm-3.0 --libs` # -lhello
CPPFLAGS = -MMD -MP `pkg-config gtkmm-3.0 --cflags` # -I../hello
CC      = $(CXX)  # link with CXX for .cpp

# target name is basename of one of the source files
main : $(patsubst %.cpp,%.o,$(wildcard *.cpp))  # .cpp
-include *.d
clean : ; -rm -fr *.o *.d
.PHONY : clean

I have not tried building gtk4 from source. I do not know whether I will encounter dependency problem in compiling it.

I’m sure you will. gtk4 depends on many modules.

The -pthread option probably comes from gmodule-no-export-2.0.pc. It’s a dependency of gio-2.0.

Both pkg-config --cflags gmodule-no-export-2.0, pkg-config --libs gmodule-no-export-2.0
and pkg-config --cflags gio-2.0 list -pthread. pkg-config --libs gio-2.0 does not.
I don’t know why. Perhaps because gio-2.0.pc lists gmodule-no-export-2.0 as Requires.private.

1 Like

Find out pkg-config options:

--libs-only-l, --libs-only-L, --cflags-only-I,

correspoding to Makefile variables:

LDLIBS, LDFLAGS, CXXFLAGS.

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