lgi-devs / lgi

Dynamic Lua binding to GObject libraries using GObject-Introspection
MIT License
436 stars 69 forks source link

Porting lgi for Lua5.4 #318

Open definetly-not-carl opened 5 months ago

definetly-not-carl commented 5 months ago

DISCLAIMER: it's not a true issue cause I know this library isn't being developed for Lua5.4

So, I have been trying to compile this library for Lua5.4. I am using Fedora 40 and I was trying to see if this library worked with some minor changes. First of all, after having installed lua-devel and compat-lua-devel, I changed, inside the makefile in the lgi library , the version from 5.1 to 5.4 I tried to run the makefile (with sudo in front of it) and it "installed", then, after having tried to run it, nothing worked. I went back to the makefile (always inside lgi folder) and, I don't know why, but I had to change PREFIX from /usr/local to /usr and in LUA_LIBDIR I changed lib to lib64. I then tried to run the makefile in the main folder again and, other than some compilation warnings, I didn't have any other problem. I then tried to run the console.lua program with lua console.lua and it gave me errors with GtkSource, so I thought it was a version problem and changed inside the lua file I was trying to run GtkSource's version from 3.0 to 4.0. I also tried to understand why it gave me problems with GtkSource, but I really don't understand much about GTK, therefore I am writing this "adventure" in order to let people start from where I failed.

Feel free to correct things I did wrong. Thanks for your attention!

psychon commented 5 months ago

Uhm... I think LGI just works with Lua 5.4. It is even checked in CI: https://github.com/lgi-devs/lgi/blob/700fcdabad23b37fe03e0bef014fcedb599a9986/.github/workflows/ci.yml#L16

But since this is Lua, it is of course not easy to get "things" to actually build against Lua 5.4. Sadly, I don't have any good suggestions on how to do that.

Some things that I can suggest:

Check which Lua version LGI was linked against:

$ readelf -a lgi/corelgilua51.so | grep NEEDED | grep liblua
 0x0000000000000001 (NEEDED)             Shared library: [liblua5.3.so.0]

Check where Lua is searching for .lua files (of course this needs to be run with the right lua binary):

$ lua -e 'print(package.path)'
/usr/local/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?/init.lua;/usr/local/lib/lua/5.4/?.lua;/usr/local/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua

Check where Lua is searching for .so files:

$ lua -e 'print(package.cpath)'
/usr/local/lib/lua/5.4/?.so;/usr/local/lib/lua/5.4/loadall.so;./?.so

All of this has to fit together. How to get things to fit depends on the specifics of the distro.

Specific of which, it might make sense to look at how your distro builds lgi. For example, Google brought me to https://src.fedoraproject.org/rpms/lua-lgi/blob/rawhide/f/lua-lgi.spec where I read %global luaver 5.4, which sounds to me like Fedora already builds LGI for Lua 5.4...?

definetly-not-carl commented 5 months ago

you're right, I found it with dnf, but it still gives me the same issue with GtkSource, I rellay don't know how to solve it 20240604_18h28m14s_grim

luau-project commented 2 months ago

[!WARNING]

These words I'm placing here is what I remember about GTK-related stuff (I might be mistaken, because I don't touch lgi / GTK in almost 2 years)

Hello @definetly-not-carl . Judging by your last comment, the lgi library complaining about the typelib for GtkSource 3.0 is most likely due the fact that the file GtkSource-3.0.typelib can not be found on your system. To fix this on Fedora 40, in my guess, you have to install the packages related to gtksourceview3 https://packages.fedoraproject.org/pkgs/gtksourceview3/gtksourceview3/fedora-40.html.

In the package, you can see in the filelist the expected entry /usr/lib64/girepository-1.0/GtkSource-3.0.typelib and the shared library.

[!NOTE]

I don't have any experience with Fedora. I'm mostly a Debian-based guy.