Getting undefined reference to `g_object_new_with_properties'
gummybears opened this issue · comments
Not sure what is happening here, but most of the samples don't work anymore
$ crystal version
Crystal 0.34.0 [4401e90f0] (2020-04-06)
LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
shard.yml
dependencies:
gobject:
github: jhass/crystal-gobject
version: ~> 0.8.0
Error when trying to run a sample
crystal build gtk_menu_and_actions.cr
M-yA-pplication.o: In function `initialize:application_id':
/home/laptop/try/gtk/lib/gobject/samples/lib/gobject/gtk/gtk.cr:4: undefined reference to `g_object_new_with_properties'
G-tk5858A-pplicationW-indow.o: In function `initialize:application:title:default_width:default_height:icon_name':
/home/laptop/try/gtk/lib/gobject/samples/lib/gobject/gtk/gtk.cr:4: undefined reference to `g_object_new_with_properties'
G-tk5858M-enuI-tem.o: In function `initialize:label':
/home/laptop/try/gtk/lib/gobject/samples/lib/gobject/gtk/gtk.cr:4: undefined reference to `g_object_new_with_properties'
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/laptop/try/gtk/lib/gobject/samples/gtk_menu_and_actions' -rdynamic -lgdk-3 -lgtk-3 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lgobject-2.0 -lglib-2.0 -lpcre -lm /usr/bin/../lib/crystal/lib/libgc.a -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/bin/../lib/crystal/lib`
What's GTK version you have installed? The samples works here with GTK version 3.24.21
.
Linux Mint 18.2, GTK version 3.18.9
The binding generator now rely on g_object_new_with_properties
to be able to construct objects passing the properties on constructor, however this function is only available since GLib version 2.54. So you need to upgrade your gtk3, 😞 , since I think there's no reason for a project like this to support old versions of GLib.
I thinks this deserves a mention on README.
So... what's your GLib version? Since this function comes from GObject library, that is usually in glib package.
I think my GLib version is too old.
$ dpkg -l gir1.2-glib-2.0
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=========================================-=========================-=========================-========================================================================================
ii gir1.2-glib-2.0:amd64 1.46.0-3ubuntu1 amd64 Introspection data for GLib, GObject, Gio and GModule
I guess this is the package for introspection of the glib package, not the glib package itself, since for sure your glib is 2.something.
Not sure how to determine the GLib version, but it is safe to say it is not the most recent.
What's your output of:
crystal eval 'require "gobject"; require_gobject("GLib"); puts "#{GLib::MAJOR_VERSION}.#{GLib::MINOR_VERSION}.#{GLib::MICRO_VERSION}"'
cat /etc/os-release
$ crystal eval 'require "gobject"; require_gobject("GLib"); puts "#{GLib::MAJOR_VERSION}.#{GLib::MINOR_VERSION}.#{GLib::MICRO_VERSION}"'
2.47.3
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial
So yeah, that's 4 years old :/ https://gitlab.gnome.org/GNOME/glib/-/tags/2.47.3
gobject_new_with_properties
was added with 2.54, which is 2 years old: https://gitlab.gnome.org/GNOME/glib/-/tags/2.54.0
The 18.04 Ubuntu LTS release ships 2.56: https://packages.ubuntu.com/bionic/libglib2.0-0
The 20.04 Ubuntu LTS release ships 2.64: https://packages.ubuntu.com/focal/libglib2.0-0
So I'm not sure it's worth to support such an old distro to be honest :/
No, you are right, I need to upgrade.
Thanks for your time and help.