Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting undefined reference to `g_object_new_with_properties' #73

Closed
gummybears opened this issue Jul 20, 2020 · 11 comments
Closed

Getting undefined reference to `g_object_new_with_properties' #73

gummybears opened this issue Jul 20, 2020 · 11 comments

Comments

@gummybears
Copy link

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`
@hugopl
Copy link
Contributor

hugopl commented Jul 20, 2020

What's GTK version you have installed? The samples works here with GTK version 3.24.21.

@gummybears
Copy link
Author

Linux Mint 18.2, GTK version 3.18.9

@hugopl
Copy link
Contributor

hugopl commented Jul 20, 2020

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.

@hugopl
Copy link
Contributor

hugopl commented Jul 20, 2020

So... what's your GLib version? Since this function comes from GObject library, that is usually in glib package.

@gummybears
Copy link
Author

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

@hugopl
Copy link
Contributor

hugopl commented Jul 20, 2020

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.

@gummybears
Copy link
Author

Not sure how to determine the GLib version, but it is safe to say it is not the most recent.

@jhass
Copy link
Owner

jhass commented Aug 19, 2020

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

@gummybears
Copy link
Author

$ 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

@jhass
Copy link
Owner

jhass commented Aug 19, 2020

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 :/

@gummybears
Copy link
Author

No, you are right, I need to upgrade.
Thanks for your time and help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants