GTK XQuartz with make

Hello readers,

Today, we bring with more tips, how to compile with make with your Apple.

As we seen before, we have this command:

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

https://gist.github.com/vic3t3chn0/313707f0372c6b89ac598181716060b4

To start, we must create a file called Makefile, we have a gist above also:

all:
	world

#clean:
#	rm example-0
# Para despues / for after for libs
world:
	rm example-0 && gcc `pkg-config --cflags gtk+-3.0` -o example-0 mainwindow.cc `pkg-config --libs gtk+-3.0`

Now we have the same source code seen before about GTK.

#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;
}

Now, we have all to start coding gtk. We must call the terminal application to go to your source code directory.

For us, we have on ~/Documents/Projects. Now you can see your files on the screen as we see ours.

We must type make world:

At last, execute your binary file on your screen terminal:

Comments

Leave a Reply

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

fifteen + two =

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.