Encountered an issue where the cinterop tool isn't...
# kotlin-native
n
Encountered an issue where the cinterop tool isn't generating the bindings for the GtkPrinter API ( https://developer.gnome.org/gtk3/3.20/GtkPrinter ). Some of the other GTK printing type APIs (eg GtkPrintSettings - https://developer.gnome.org/gtk3/3.20/GtkPrintSettings) have generated bindings. Does anyone know of any cases where the cinterop tool fails to generate bindings for something that isn't a non trivial C Macro?
👍 1
p
Maybe @Clocks knows something about this, as they did a GTK3 kotlin native library recently? (just pinging for attention)
c
I'll look into this, One moment
The gtkprinter.h is located in another library
👍 1
gtk-unix-print-2.0
Strange as it is part of gtk
Alright so the should be solution is to create a new def with the linked for the print library
I just don't know if we can do that because you'll be rebuilding the interop due to it being a duplicate of gtk with a few additions
I got it working, You can checkout my library for the def file
n
That header file is part of the Unix Print (low level printing API) stuff for Gtk, eg:
Copy code
/usr/include/gtk-3.0/unix-print/gtk/gtkpagesetupunixdialog.h
/usr/include/gtk-3.0/unix-print/gtk/gtkprinter.h
/usr/include/gtk-3.0/unix-print/gtk/gtkprintjob.h
/usr/include/gtk-3.0/unix-print/gtk/gtkprintunixdialog.h
/usr/include/gtk-3.0/unix-print/gtk/gtkunixprint-autocleanups.h
/usr/include/gtk-3.0/unix-print/gtk/gtkunixprint.h
Looks like the high level printing API comes from the gtk.h file.
c
It doesn't sadly, otherwise it would have been included
My gtkunixprint.def file adds the high level files
n
The high level printing API is available when the following is used in the gtk3.def file (linking metadata):
Copy code
linkerOpts = -lgtk-3 -lgdk-3 -latk-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo
linkerOpts.linux_x64 = -L/usr/lib/x86_64-linux-gnu
linkerOpts.linux_arm32_hfp = -L/mnt/pi_image/usr/lib/arm-linux-gnueabihf
And the following is used in the build.gradle.kts file (header metadata):
Copy code
// ...
kotlin {
linuxX64("linuxX64") {
        // ...
        compilations.getByName("main") {
            cinterops.create("gtk3") {
                val userIncludeDir = "/usr/include"
                includeDirs(
                    "$userIncludeDir/atk-1.0",
                    "$userIncludeDir/gdk-pixbuf-2.0",
                    "$userIncludeDir/cairo",
                    "$userIncludeDir/pango-1.0",
                    "$userIncludeDir/gtk-3.0",
                    "$userIncludeDir/glib-2.0",
                    "/usr/lib/x86_64-linux-gnu/glib-2.0/include"
                )
            }
}
linuxArm32Hfp("linuxArm32") {
        // ...
        compilations.getByName("main") {
            cinterops.create("gtk3") {
                val userIncludeDir = "/mnt/pi_image/usr/include"
                includeDirs(
                    "$userIncludeDir/atk-1.0",
                    "$userIncludeDir/gdk-pixbuf-2.0",
                    "$userIncludeDir/cairo",
                    "$userIncludeDir/pango-1.0",
                    "$userIncludeDir/gtk-3.0",
                    "$userIncludeDir/glib-2.0",
                    "/mnt/pi_image/usr/lib/arm-linux-gnueabihf/glib-2.0/include"
                )
            }
}
}