GTK4 macOS: helloworld c prog not loading @rpath/libpangocairo-1.0.0.dylib

Testing simple helloworld.c program on macOS Sonoma M1 Apple Silicon. Code compiles clean:

cc helloworld.c -o helloworld `pkg-config gtk4 --cflags pkg-config gtk4 --libs`

however when executing I get the following error:

./helloworld 
dyld[1250]: Library not loaded: @rpath/libpangocairo-1.0.0.dylib
  Referenced from: <9B4BB6BB-9095-35AE-94D5-F054F3A768B3> /Users/XYZ/temp/GSTREAMER/GTK/helloworld
  Reason: no LC_RPATH's found
zsh: abort      ./helloworld

Using otool I get the following:

otool -L helloworld 
helloworld:
	/opt/homebrew/opt/gtk4/lib/libgtk-4.1.dylib (compatibility version 1401.0.0, current version 1401.4.0)
	@rpath/libpangocairo-1.0.0.dylib (compatibility version 5001.0.0, current version 5001.11.0)
	@rpath/libpango-1.0.0.dylib (compatibility version 5001.0.0, current version 5001.11.0)
	@rpath/libharfbuzz.0.dylib (compatibility version 50301.0.0, current version 50301.0.0)
	@rpath/libgdk_pixbuf-2.0.0.dylib (compatibility version 4201.0.0, current version 4201.10.0)
	@rpath/libcairo-gobject.2.dylib (compatibility version 2.0.0, current version 2.0.0)
	@rpath/libcairo.2.dylib (compatibility version 2.0.0, current version 2.0.0)
	@rpath/libgraphene-1.0.0.dylib (compatibility version 1001.0.0, current version 1001.8.0)
	@rpath/libgio-2.0.0.dylib (compatibility version 7401.0.0, current version 7401.4.0)
	@rpath/libgobject-2.0.0.dylib (compatibility version 7401.0.0, current version 7401.4.0)
	@rpath/libglib-2.0.0.dylib (compatibility version 7401.0.0, current version 7401.4.0)
	@rpath/libintl.8.dylib (compatibility version 10.0.0, current version 10.5.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.120.2)

Code is below. Note: this exact code runs without errors as expected against an Intel MacBook Pro running macOS Big Sur.

Please help with any tips so I can try to resolve. Many thanks.

My Code (this is a GTK example program / tutorial):

#include <gtk/gtk.h>

static void
print_hello (GtkWidget *widget,
             gpointer   data)
{
  g_print ("Hello World\n");
}

static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *window;
  GtkWidget *button;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Hello");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  button = gtk_button_new_with_label ("Hello World");
  g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
  gtk_window_set_child (GTK_WINDOW (window), button);

  gtk_window_present (GTK_WINDOW (window));
}

int
main (int    argc,
      char **argv)
{
  GtkApplication *app;
  int status;

  app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);

  return status;
}

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