valagobject

How can i use C libraries in Vala? Or how to use g-ir-scanner?


How can i use C libraries in Vala? As written in GNOME documentation, I need to scan my C headers by command line tool g-ir-scanner to generate *.GIR file and then generate VAPI (Vala API) file with $ vapigen --library MyLibrary MyLibrary.gir to use in Vala.

Everything is clear except using g-ir-scanner. How to use this tool?

Or how to create bindings without this tool?


Solution

  • "g-ir-scanner is made for libraries built with GObject and has to be used in the source code of the library. For other libraries you unfortunately have to create it by hand. It's best to reuse the ones from here https://gitlab.gnome.org/GNOME/vala-extra-vapis but if it's not here you have to make it from scratch" (