gtk with XQuartz

Hello readers,

We are going to learn how to compile gtk3 for XQuartz on big sur.

To compile use this:

gcc `pkg-config –cflags gtk+-3.0` -o example-0 mainwindow.cc `pkg-config –libs gtk+-3.0`

But first, open my gtk gist:

https://gist.github.com/vic3t3chn0/2e082126a7f89330f04cf2b10ba6e8c2

But you can test it like this:

#include <gtk/gtk.h>

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

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Window");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
  gtk_widget_show_all (window);
}

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

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

  return status;
}

in the end:

 gcc `pkg-config --cflags gtk+-3.0` -o example-0 mainwindow.cc `pkg-config --libs gtk+-3.0`

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

fourteen − 4 =

coder by Gleentech
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.