I’m trying to run a Hello World with C++ and GTK4, but when I try to build it Meson doesn’t find the gtkmm-4.0 library.
I’ve followed the gtkmm documentation, installed the library and pkg-config and was able to build it using g++ simple.cc -o simple 'pkg-config --cflags --libs gtkmm-4.0' -std=c++17
as specified in the documentation.
But when I tried to build it in Builder, Meson isn’t able to find the library.
I’ve followed the instructions here to add the dependency to meson.build.
Here’s my meson.build file inside /src:
hello_sources = [
'main.cpp',
]
hello_deps = [dependency('gtkmm-4.0')
]
executable('hello', hello_sources,
dependencies: hello_deps,
install: true,
)
and my main.cpp:
#include <gtkmm.h>
class MyWindow : public Gtk::Window
{
public:
MyWindow();
};
MyWindow::MyWindow()
{
set_title("Basic application");
set_default_size(200, 200);
}
int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.examples.base");
return app->make_window_and_run<MyWindow>(argc, argv);
}
The logs resulted from the failed build:
-----------
C++ compiler for the build machine: ccache c++ (gcc 13.2.0 "c++ (GCC) 13.2.0")
C++ linker for the build machine: c++ ld.bfd 2.43.1
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64
Pkg-config binary missing from cross or native file, or env var undefined.
Trying a default Pkg-config fallback at pkg-config
Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
Determining dependency 'gtkmm-4.0' with pkg-config executable '/usr/bin/pkg-config'
env[PKG_CONFIG_PATH]: /app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
env[PKG_CONFIG]: /usr/bin/pkg-config
-----------
Called: `/usr/bin/pkg-config --modversion gtkmm-4.0` -> 1
stderr:
Package gtkmm-4.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-4.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtkmm-4.0' not found
Could somebody help me find the mistake and understand why is Meson trying to find the library with --modversion
? Thanks ^^