mattn / go-gtk

Go binding for GTK
http://mattn.github.com/go-gtk
BSD 3-Clause "New" or "Revised" License
2.12k stars 247 forks source link

Compilation problems - undefined reference to symbol 'g_object_unref' #395

Open Anty0 opened 5 years ago

Anty0 commented 5 years ago

I'm heaving problems with go-gtk installation on my machine.

I have used this command: go get github.com/mattn/go-gtk/gtk And got this output: # github.com/mattn/go-gtk/pango /usr/bin/ld: $WORK/b032/_x002.o: undefined reference to symbol 'g_object_unref' /usr/bin/ld: /usr/lib/libgobject-2.0.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

Unfortunanely online search didn't help me how to solve this issue.

Info: OS: Arch Linux (64bit)

~ go version go version go1.11.4 linux/amd64

~ go env GOARCH="amd64" GOBIN="" GOCACHE="/home/anty/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/anty/go" GOPROXY="" GORACE="" GOROOT="/usr/lib/go" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build919250187=/tmp/go-build -gno-record-gcc-switches"

Anty0 commented 5 years ago

I only know so far, that I can successfully install this, when this line is commented out in pango.go: func (v *Layout) Unref() { C.g_object_unref(C.gpointer(v.GLayout)) } func (v *Layout) Unref() { // C.g_object_unref(C.gpointer(v.GLayout)) }

Anty0 commented 5 years ago

I have managed to fix this problem by modifying this line in pango.go: // #cgo pkg-config: pango // #cgo pkg-config: pango gobject-2.0

But unfortunately I'm not sure if this is proper fix or workaround. (It does seem more like workaround.) Can someone can confirm, if this is proper fix?

QuLogic commented 5 years ago

That is correct. Previously, the pango pkgconfig file included gobject-2.0 and they removed it. It did causes issues like this one so they intend to bring it back.

However, if this code uses GObject functions (like g_object_unref), then it should also include gobject-2.0 itself and not rely on other packages to maybe provide it for them, since as you can see, it might break.

Anty0 commented 5 years ago

Thank you for confirmation.

In case this issue will not be fixed faster, I might be able to find some time to create pull request this weekend.

Francesco149 commented 5 years ago

it looks like arch fixed this in pango 1.43.0-2 but manjaro stable hasnt picked up the change yet. https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/pango&id=d0516bfe5e6fda19d1ef5560509001bfdf6e846b

Francesco149 commented 5 years ago

looks like manjaro picked up the update now, please update pango and see if it builds