AndyObtiva / glimmer-dsl-libui

Glimmer DSL for LibUI - Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library - The Quickest Way From Zero To GUI - If You Liked Shoes, You'll Love Glimmer! - No need to pre-install any prerequisites. Just install the gem and have platform-independent GUI that just works on Mac, Windows, and Linux.
MIT License
497 stars 15 forks source link

Raspberry PI 4 support #23

Open map7 opened 2 years ago

map7 commented 2 years ago

Error when running on Raspberry PI 4 with debian buster and ruby 2.5.5 with the following example;

Code

#!/usr/bin/env ruby
require 'glimmer-dsl-libui'
include Glimmer
window('hello world').show

Error

/usr/lib/ruby/2.5.0/fiddle/import.rb:89:in `rescue in block in dlload': can't load /var/lib/gems/2.5.0/gems/libui-0.0.15/vendor/libui.so (Fiddle::DLError)
    from /usr/lib/ruby/2.5.0/fiddle/import.rb:86:in `block in dlload'
    from /usr/lib/ruby/2.5.0/fiddle/import.rb:77:in `collect'
    from /usr/lib/ruby/2.5.0/fiddle/import.rb:77:in `dlload'
    from /var/lib/gems/2.5.0/gems/libui-0.0.15/lib/libui/ffi.rb:10:in `<module:FFI>'
    from /var/lib/gems/2.5.0/gems/libui-0.0.15/lib/libui/ffi.rb:5:in `<module:LibUI>'
    from /var/lib/gems/2.5.0/gems/libui-0.0.15/lib/libui/ffi.rb:4:in `<top (required)>'
    from /var/lib/gems/2.5.0/gems/libui-0.0.15/lib/libui.rb:20:in `require_relative'
    from /var/lib/gems/2.5.0/gems/libui-0.0.15/lib/libui.rb:20:in `<module:LibUI>'
    from /var/lib/gems/2.5.0/gems/libui-0.0.15/lib/libui.rb:5:in `<top (required)>'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /var/lib/gems/2.5.0/gems/glimmer-dsl-libui-0.5.5/lib/glimmer-dsl-libui.rb:36:in `<top (required)>'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
    from ./test_glimmer_hello.rb:7:in `<main>'
kojix2 commented 2 years ago

Hello. @map7

I'm kojix2 and I'm working on LibUI backend for glimmer-dsl-libui. Maybe you have to recompile C libui if you want to use Raspberry PI, because the shared libraries for ARM on Linux are not included in the LibUI gem.

So you need to get either andlabs/libui or libui-ng/libui-ng yourself. I know C libui for Linux uses GTK internally, but I believe GTK worked on Raspbian.

https://github.com/kojix2/LibUI/issues/46#issuecomment-1041575792

AndyObtiva commented 2 years ago

@map7 Raspberry PI 4 uses an ARM processor on Linux. Currently, like @kojix2 mentioned, the LibUI backend only includes support for Mac ARM/x64 and Linux x86_64 out of the box (and Win x64 of course), but not Linux ARM (aka AARCH64). I linked this issue to a LibUI backend issue regarding AARCH64 support. Once it is addressed, you will be notified. In the meantime, you can use @kojix2 's workaround of compiling C libui for Linux ARM (AARCH64) manually if you don't want to wait.

kojix2 commented 2 years ago

@map7 I have a Raspberry Pi 3. But I just bought it and haven't used it for a long time. This time I will compile libui-ng and make sure glimmer-dsl-libui works.

First I installed meson and libgtk-3-dev with the apt command. This time I also installed Ruby with apt, Ruby 2.5. It is a little bit old. I created a symbolic link libui.so to libui.so.0, set the environment variable LIBUIDIR, cloned the glimmer-dsl-libui repository and launched Meta-Example.

image

I launched many windows! Hey, it's much more than I expected. Raspberry Pi is quite a powerful computer!

image

@AndyObtiva Actually, I had no plans to add Linux ARM. So I was fine with this issue being closed. There are a lot of people using M1 Macs, and there will be more in the future. Ruby users tend to use Macs. So it's important to support M1 Macs. But I didn't think there were many people using Linux ARM. But yes, the Raspberry Pi is ARM. If we get enough requests, then, I will consider adding it.

AndyObtiva commented 2 years ago

@kojix2 I disagree with your statement about not many people using Linux ARM. It has become a standard offering in most Linux distributions and I know many libraries supporting Linux ARM (AARCH64) like SWT. Linux ARM is now a first-class citizen and must be supported out of the box in any library claiming to be cross-platform.

It is important to provide a good programming experience to Linux ARM (AARCH64) users just like any other platform users.

And, by the way, there are many users of Ruby who run on Linux in addition to Mac and Windows. I encounter such users regularly in my open-source project issues. Ruby in fact runs on Linux better than Windows, so it is very important to support completely in Ruby libraries.

map7 commented 2 years ago

@kojix2 I think glimmer-dsl-libui is a great project and would love to see it work easily on the Raspberry PI 4. Thanks for the documentation I'll try and install it on my Raspberry PIs.

I have a few Raspberry PIs in which I use ruby on with GUIs, some where using the GTK old library and another uses Shoes, both of which are unmaintained or hard to use. I like using glimmer as it's much lighter and easier to use. I think it would benefit the project to be easily accessible on the PI.

AndyObtiva commented 1 year ago

I know it's been a while, but better late than never! I forgot to mention that @kojix2 did eventually support the Raspberry PI several months ago.

I don't have a Raspberry PI, so I cannot test the support at the moment, but I will look into finding an environment where I could test it.

Still, I'd say try the latest glimmer-dsl-libui in case the newly included libui (0.1.2.pre , updated relatively recently) works with Raspeberry PI on Aarch64 on Linux out of the box (I am not sure if @kojix2 included that support in the latest libui gem by default).

If that doesn't work, then pull @kojix2 's project: https://github.com/kojix2/LibUI

Afterwards, enter the project and bundle

Finally, if you run rake -T, it will mention an option to download the binaries for Raspberry PI (rake vendor:kojix2:raspbian_64).

Run the Raspberry PI rake task and it should download the right binaries for it.

If you install glimmer-dsl-libui on top of there, it should use those binaries.

If this works for you, please let us know.

kojix2 commented 1 year ago

Thanks for your comments. I have not yet merged the PR to support Raspberry Pi. So, as Andy said, we need to execute the following command.

rake vendor:kojix2:raspbian_64
rake install

It downloads binaries created with GitHub Actions using pguyot/arm-runner-action.

However, this is not something that has been tested on an actual device, so it may be better to build libuii-ng yourself, as shown below.

rake vendor:libui-ng:build
rake install