Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 862225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:06:25+00:00 2026-05-15T09:06:25+00:00

I am trying to create python bindings to a vala library using pygi with

  • 0

I am trying to create python bindings to a vala library using pygi with gobject introspection. However, I am having trouble generating the GIR files (that I am planning to compile to typelib files subsequently). According to the documentation valac should support generating GIR files.

Compiling the following

helloworld.vala

public struct Point {
    public double x;
    public double y;
}

public class Person {

    public int age = 32;

    public Person(int age) {
        this.age = age;
    }

}

public int main() {

    var p = Point() { x=0.0, y=0.1 }; 
    stdout.printf("%f %f\n", p.x, p.y);

    var per = new Person(22);
    stdout.printf("%d\n", per.age);

    return 0;

}

with the command

valac helloworld.vala --gir=Hello-1.0.gir

doesn’t create the Hello-1.0.gir file as one would expect. How can I generate the gir file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:06:26+00:00Added an answer on May 15, 2026 at 9:06 am

    To generate the GIR one has to put the functions to be exported under the same namespace

    hello.vala

    namespace Hello {
        public struct Point {
            public double x;
            public double y;
        }
    
        public class Person {
    
            public int age = 32;
    
            public Person(int age) {
                this.age = age;
            }
        }
    }
    
    public int main() {
    
        var p = Hello.Point() { x=0.0, y=0.1 }; 
        stdout.printf("%f %f\n", p.x, p.y);
    
        var per = new Hello.Person(22);
        stdout.printf("%d\n", per.age);
    
        return 0;
    
    }
    

    and then run the following command.

    valac hello.vala --gir=Hello-1.0.gir --library Hello-1.0
    

    This will generate a gir and a vapi file in the current directory.

    Then to generate the typelib file, one needs to run

    g-ir-compiler --shared-library=hello Hello-1.0.gir -o Hello-1.0.typelib
    

    assuming the shared library has been compiled to libhello.so

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create python bindings to a vala library using the following
I'm trying to create a GUI Python app using Py2App, but am having trouble
I'm trying to create python bindings for source-highlight-qt using sip. I'm working on ubuntu
I'm trying to create a python program (using pyUNO ) to make some changes
I am attempting to create python bindings for some C++ code using swig. I
I'm trying to use VLC's python bindings to create my own little video player.
I'm trying to create a python script that logs into JIRA using their REST
I am trying to create a csv file using python that is truly Excel-compatible
I am trying to create a simple web app using Python on GAE. The
I am trying to create a 3D bar histogram in Python using bar3d() in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.