The Crystal Programming Language Forum

Crystal Qt5 undefined method

Hello, today I tried to use the Qt5 library with crystal, I followed the instruction, but when I tried to run the example from the website, this don’t work, I have this strange error:

~/Documents/Programmation/Pokémon ❯❯❯ crystal build Test.cr 
Showing last frame. Use --error-trace for full trace.

In lib/qt5/src/qt5/binding.cr:7:20

 7 | {% use_binding = run("#{__DIR__}/../../support/decide_binding_fast.cr") %}
                      ^--
Error: Error executing run (exit code: 1): '/home/zohran/Documents/Programmation/Pokémon/lib/qt5/src/qt5/../../support/decide_binding_fast.cr' 


stdout:

    


stderr:

    Showing last frame. Use --error-trace for full trace.
    
    In support/decide_binding_slow.cr:7:8
    
     7 | YAML.mapping(find_paths: Bindgen::FindPath::Configuration)
              ^------
    Error: undefined method 'mapping' for YAML:Module
    Unhandled exception: Support script decide_binding_slow.cr failed (Exception)
      from ???
      from ???
      from __crystal_main
      from main
      from __libc_start_main
      from _start
      from ???

This is my Test.cr:

require "qt5"

qApp = Qt::Application.new

label = Qt::Label.new "Hello from Crystal/Qt!"
label.show

Qt::Application.exec

The Qt5 github compatibility for Crystal: GitHub - Papierkorb/qt5.cr: Qt5 bindings for Crystal, based on Bindgen

The gist of it is that that shard is old and currently doesn’t support Crystal 1.x.

There’s currently a PR for it: Crystal 1.0.0 by kalinon · Pull Request #46 · Papierkorb/qt5.cr · GitHub.