Skip to content

Instantly share code, notes, and snippets.

@terhechte
Last active January 23, 2016 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terhechte/c48fff0eb7e581d676b2 to your computer and use it in GitHub Desktop.
Save terhechte/c48fff0eb7e581d676b2 to your computer and use it in GitHub Desktop.
GTK3 Linux Swift header issues
/**
I tried to get GTK running with Swift. To run this, a Linux machine with a working GTK3
installation is needed (could also work with OSX && brew install gtk+3, however I did not try that);
i.e.
`sudo apt-get install libgtk-3-dev`
Initially I tried with GTK but since GTK has dependencies to a lot of other things, I tried something
simpler, i.e. in this case GDK which has only dependencies to X11.
I'm aware that GTK is a difficult system, and not easy to link against, however I thought I'd share
these header issues nevertheless.
*/
// First try
module CGTK [system] {
umbrella header "/usr/include/gtk-3.0/gdk/gdk.h"
link "gdk-3"
export *
}
/*
Error:
Cloning Packages/CGTK
Compiling Swift Module 'example' (1 sources)
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "/usr/include/gtk-3.0/gdk/gdk.h"
^
/usr/include/gtk-3.0/gdk/gdk.h:30:10: error: 'gdk/gdkconfig.h' file not found
#include <gdk/gdkconfig.h>
*/
/**
Setting an umbrella directory also failed:
*/
module CGTK [system] {
umbrella "/usr/include/gtk-3.0/gdk/"
link "gdk-3"
export *
}
/*
Cloning Packages/CGTK
Compiling Swift Module 'example' (1 sources)
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "/usr/include/gtk-3.0/gdk/x11/gdkx11dnd.h"
^
/usr/include/gtk-3.0/gdk/x11/gdkx11dnd.h:22:2: error: "Only <gdk/gdkx.h> can be included directly."
#error "Only <gdk/gdkx.h> can be included directly."
*/
/**
I also tried adding X11, just to make sure that this wasn't the issue
*/
module CX11 [system] {
module Xlib {
header "/usr/include/X11/Xlib.h"
}
module X {
header "/usr/include/X11/X.h"
}
link "X11"
}
module CGTK [system] {
module gdk [system] {
umbrella header "/usr/include/gtk-3.0/gdk/gdk.h"
link "gdk-3"
export *
}
use CX11
}
/**
Same error:
Cloning Packages/CGTK
Compiling Swift Module 'example' (1 sources)
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "/usr/include/gtk-3.0/gdk/gdk.h"
^
/usr/include/gtk-3.0/gdk/gdk.h:30:10: error: 'gdk/gdkconfig.h' file not found
#include <gdk/gdkconfig.h>
*/
/**
gdkconfig is obviously in the folder:
terhechte@terhechte-virtual-machine:~/Desktop/example$ ls -l /usr/include/gtk-3.0/gdk/
total 480
drwxr-xr-x 2 root root 4096 Dez 8 10:48 broadway
drwxr-xr-x 2 root root 4096 Dez 8 10:48 deprecated
-rw-r--r-- 1 root root 2995 Okt 16 11:46 gdkapplaunchcontext.h
-rw-r--r-- 1 root root 1892 Okt 16 11:46 gdk-autocleanup.h
-rw-r--r-- 1 root root 1381 Okt 16 11:46 gdkbroadway.h
-rw-r--r-- 1 root root 3673 Okt 16 11:46 gdkcairo.h
-rw-r--r-- 1 root root 445 Okt 16 11:46 gdkconfig.h
-rw-r--r-- 1 root root 8259 Okt 16 11:46 gdkcursor.h
-rw-r--r-- 1 root root 11047 Okt 16 11:46 gdkdevice.h
-rw-r--r-- 1 root root 1859 Okt 16 11:46 gdkdevicemanager.h
-rw-r--r-- 1 root root 7461 Okt 16 11:46 gdkdisplay.h
-rw-r--r-- 1 root root 2430 Okt 16 11:46 gdkdisplaymanager.h
-rw-r--r-- 1 root root 7124 Okt 16 11:46 gdkdnd.h
-rw-r--r-- 1 root root 5895 Okt 16 11:46 gdkenumtypes.h
-rw-r--r-- 1 root root 45037 Okt 16 11:46 gdkevents.h
-rw-r--r-- 1 root root 4926 Okt 16 11:46 gdkframeclock.h
-rw-r--r-- 1 root root 2018 Okt 16 11:46 gdkframetimings.h
-rw-r--r-- 1 root root 3886 Okt 16 11:46 gdkglcontext.h
-rw-r--r-- 1 root root 2109 Okt 16 11:46 gdk.h
-rw-r--r-- 1 root root 6212 Okt 16 11:46 gdkkeys.h
-rw-r--r-- 1 root root 73184 Okt 16 11:46 gdkkeysyms-compat.h
-rw-r--r-- 1 root root 82512 Okt 16 11:46 gdkkeysyms.h
-rw-r--r-- 1 root root 4766 Okt 16 11:46 gdkmain.h
-rw-r--r-- 1 root root 1766 Okt 16 11:46 gdkmir.h
-rw-r--r-- 1 root root 2394 Okt 16 11:46 gdkpango.h
-rw-r--r-- 1 root root 2064 Okt 16 11:46 gdkpixbuf.h
-rw-r--r-- 1 root root 1494 Okt 16 11:46 gdkprivate.h
-rw-r--r-- 1 root root 3715 Okt 16 11:46 gdkproperty.h
-rw-r--r-- 1 root root 1889 Okt 16 11:46 gdkrectangle.h
-rw-r--r-- 1 root root 2055 Okt 16 11:46 gdkrgba.h
-rw-r--r-- 1 root root 5257 Okt 16 11:46 gdkscreen.h
-rw-r--r-- 1 root root 5660 Okt 16 11:46 gdkselection.h
-rw-r--r-- 1 root root 2307 Okt 16 11:46 gdktestutils.h
-rw-r--r-- 1 root root 4398 Okt 16 11:46 gdkthreads.h
-rw-r--r-- 1 root root 17452 Okt 16 11:46 gdktypes.h
-rw-r--r-- 1 root root 10597 Okt 16 11:46 gdkversionmacros.h
-rw-r--r-- 1 root root 5577 Okt 16 11:46 gdkvisual.h
-rw-r--r-- 1 root root 1416 Okt 16 11:46 gdkwayland.h
-rw-r--r-- 1 root root 45981 Okt 16 11:46 gdkwindow.h
-rw-r--r-- 1 root root 1961 Okt 16 11:46 gdkx.h
drwxr-xr-x 2 root root 4096 Dez 8 10:48 wayland
drwxr-xr-x 2 root root 4096 Dez 8 10:48 x11
*/
@cellularmitosis
Copy link

any progress on this?

@charlienovember
Copy link

I have managed to get it past this first error by installing swift on /usr/lib and using the following module.modulemap

module CGTK [system] {
  module Gdk {
    umbrella "/usr/include/gtk-3.0/gdk/"
  }

  module Glib {
    umbrella "/usr/include/glib-2.0/glib"

}

But then it dies on me, I think that first you need to create a CGlib module, then a CGTK module depending on that first one... I'll keep looking.

@kirushyk
Copy link

Any repos to take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment